« first day (3100 days earlier)      last day (1865 days later) » 

2:00 PM
but some things are allowed there and now forbidden
>>> def foo(x, (y,z)):
...     print x,y
...
>>> foo(2, [3, 4])
2 3
Why do you ask? :P
 
didn't even list all of the possible uses for * smh
 
hmm
 
(def func(*args):, def func(*, kw_only_arg=None):, [*'foobar'])
 
aren't all those unpacking?
 
Not really? Only the 3rd one actually "unpacks" something, and I'm pretty sure it's different from argument unpacking because AFAIK python 2 doesn't support unpacking in literals
The 1st one is the opposite of unpacking, really
 
2:07 PM
packing
 
yeah
 
hmm, they're very much unpacky in my head
 
Cabbage. I was given a Rubik's cube not long after they first became available in Australia. I don't have great 3D visualisation skills, but I'm ok. I used to be competent at solving Rubik's cube, and creating patterns on it, but I was never a speed solver. I've hardly touched it in the last 10 years or so, and when I was messing around with one a couple of months ago, I got a bit lost, and realised I'd forgotten a couple of important algorithms. :(
 
the tutorial calls them "variadic arguments" which makes sense (and the second is a special case of the first, again in my head)
 
Yeah somehow I can't unpack what I wanted the way I'm used to and I think it's python2 being funny. I just changed it a bit
 
2:12 PM
bah, the parentheses there were meant to be put there
 
@ParitoshSingh Ken Thompson, one of the original creators of Unix (along with Dennis Ritchie, creator of C), gave an interesting talk on trusting computer systems. From wiki.c2.com/?TheKenThompsonHack
In 1984 KenThompson was presented with the ACM TuringAward. Ken's acceptance speech Reflections On Trusting Trust (http://cm.bell-labs.com/who/ken/trust.html) describes a hack (in every sense), the most subversive ever perpetrated, nothing less than the root password of all evil.

Ken describes how he injected a virus into a compiler. Not only did his compiler know it was compiling the login function and inject a backdoor, but it also knew when it was compiling itself and injected the backdoor generator into the compiler it was creating. The source code for the compiler thereafter contains
 
And on the topic of closed vs open source, Eric S. Raymond's seminal essay, The Cathedral and the Bazaar is essential reading. He also expanded the essay into a full book, although I haven't read the book.
 
I have some questions about Google's APIs, is anyone here familiar with it (Geocoding API)?
 
@Renan Please read our room rules.
 
2:25 PM
where?
 
@Renan You have Daniel Roseman, one of the most senior & expert coders on SO trying to help you. I suggest that you try to communicate & cooperate with him.
 
@Renan Link in the upper right corner. Or: sopython.com/chatroom
 
ok, thank you.
 
TLDR: posting links to new-ish questions won't get many fresh eyes on your post, since most of us are watching the new questions list anyway.
 
Pet peeve: the room rules are invisible on mobile devices, unless you use the desktop view, which is impractical to use for chatting.
 
2:28 PM
yup
 
I wonder if SO would auto post an inline message that allows RO to fill that message, for mobile users upon joining
 
feelsbadman
 
i didnt knhow
 
I suspect that most help seekers are desktop users, since typing out a whole question on mobile seems like a real pain in the butt
But maybe I underestimate the propensity for cord cutting that Today's Youth possesses.
 
2:36 PM
@Kevin I'd definitely get lost if I thought of a Rubik's cube in terms of the 54 tiles. I think in terms of the sub-cubes, aka cubies. To solve a cube, I first move the corner cubies to their proper locations, with reference to the face centre cubies. Then fix the corner cubie orientations. Then do the same thing with the edge cubies, using sequences that leave the corners unchanged.
 
I think I've heard of that approach before. I never graduated past "solve one face, then solve the middle stripe, then solve the final face's corners, then solve the final face's edges" which I understand is basically Babby's First Solution
 
Oh actually pycharm tells me what was wrong :P python 2.7 version does not support * expression in tuples, list ...
 
that took long enough
 
I attempted to learn more sophisticated techniques but the first one I encountered began with "you will have to memorize a different move sequence for every possible permutation of this face's edge and corner colors"
 
@PM2Ring It got a bit out of hand because I don't believe I've ever solved one in my life. It was a maths question for 16 yr olds I was answering while walking down the street and I was just surprised that my friend, who has much better recall than me couldn't even visualise a cube in his head, let alone manipulate it.
 
2:41 PM
There were some preconditions that limited the total number of permutations, so it wasn't quite 8 factorial possibilities or whatever, but there were still more than my brain could sponge up
 
@AndrasDeak ah, straightforward error edited
 
Then again, he was studying films. I did a teaching placement for maths in a secondary school. I spent quite a bit of time with the "remedial" class, if that's the word for it these days
 
@roganjosh "Behavioural Intervention Classroom."
 
Shell had developed a pretty cool app about a virus outbreak and they only had something like 95k vaccines. They had to choose how many binmen or doctors they would save. The implication being that if you didn't save binmen then disease would spread
It took me nearly 20 minutes working with one girl to realise that she literally couldn't envisage a number greater than 100
 
@roganjosh Binmen - haven't heard that term in several years :)
 
2:47 PM
She saved 100 of all the professions and just threw away the rest of the vaccines. Nothing would persuade her to save more.
 
@Kevin My approach is pretty similar to your, since I do solve the top face as part of my corner solving phase. :) When I got my 1st cube, my girlfriend & I made a game of doing 3 secret (quarter-turn) moves on the cube and giving it to the other person to solve. We got pretty fast at that. But doing it on 4 or more random moves is hard!
 
@toonarmycaptain binpeople I guess :)
It was at that point that I realised that I'd probably never understand how others view problems
 
@roganjosh Long term survival of a population...proportions of professions to eachother might need work, but numbers that low might have an advantage over saving more people in the short term...
 
IIRC finding the shortest possible solution for a given cube is a problem that not even computers can efficiently solve
 
@roganjosh I've come through the UK/Australia to the US, so in my head it's "dust bin man" but obviously that's not really a phrase my wife (American) automatically parses.
 
2:49 PM
@toonarmycaptain she threw the vaccines away
 
Vision shows us surfaces, so it's actually 2D. Our brains have to build a dynamic model to simulate a 3D world out of that.
 
100 of everyone saved. Good enough. Might as well dump the rest.
GP waiting times were down like 10000%
 
@roganjosh Oh I'm not suggesting it's sensible, it just occurred to me that when running that sim, saving just 100 of everyone might have advantages over maximising population survival short term. I'd be interested in playing that.
 
But, on a serious note, I still cannot understand what limited her to 100
Or even why it was 100
 
utter lack of abstraction skills
maybe even discalculia
 
2:54 PM
It was really sad, she was really sweet and I tried for most of my placement to present the problem in different ways. Brains just work in different ways.
 
@roganjosh My son kinda goes 100, 200, a million billion trillion in his conception of numbers. He's 6. I don't know if this is relevent/related.
 
She was 13 I think
 
And his 200 is "what's 1 hundred plus 1 hundred" right now, so it's named but I don't think conceived.
@roganjosh I wouldn't be surprised if there were some educational deficits...my wife has had middle and high school students needing calculators for basic operations with single digit integers, so..
 
But that, combined with someone I know is well above average in intelligence not being able to visualise objects in their head does pull a lot of things into question
 
@Kevin Yep. God's Algorithm is hard. The proof of its length took years of CPU time. You can read about it at cube20.org The leader of that group is Tomas Rokicki, a programmer from Palo Alto.
Incidentally, Tomas was an Amiga programmer, and his Amiga program for Conway's Life was blazingly fast. It used the Amiga's blitter, one of the core hardware components behind Amiga's amazing graphics capability, to compute cell states in parallel. It was the grandfather of the modern technique if using the GPU for parallel processing.
 
3:06 PM
@toonarmycaptain ugh, there was a news article recently that they had to change exam clocks here because students couldn't read non-digital clocks
How much of this is true, I don't know
 
Oh rad, I didn't know they actually established the number to be 20. Shows how out of the loop I am.
 
@roganjosh :/
 
FWIW, I just noticed there's a low rep user on SO named Tomas Rokicki, but I don't know if it's him. Probably just a fan. Or a coincidence.
 
Actually...I don't remember even always having a clock, just times written and crossed off the board, or time-to-go written and crossed off.
 
> With about 35 CPU-years of idle computer time donated by Google, a team of researchers has essentially solved every position of the Rubik's Cube.
This is why it took so long to get a picture of the black hole... All the computers were busy with Rubik's Cubes
 
3:08 PM
a noble cause
 
@Kevin I'm sure in 20 years we'll see the fruits, just like electricity and penicillin had no application when first studied. That research will probably enable us to travel through wormholes.
 
@roganjosh I can work with multidimensional arrays, but I don't try too hard to visualise them. I find recursive tree structures easier. There's an old joke: someone asks their maths professor "How do you visualise a 9 dimensional space?" The professor replies: "First visualize it in N- dimensional space, then let N go to 9."
 
Finding God's Number or compressing a zillion petabytes into a 10kb png of a black hole is plenty fruitful to me :-)
 
@PM2Ring hence why I said I couldn't be a physicist :) I can either visualise it in my head or la la la la :P
 
Speaking of black holes, I bet if there were a video on YouTube of Dr Katie Bowman Bouman looking at the M87* image on a computer monitor and saying "My God, it's full of stars!", it would go viral. :D
 
3:18 PM
There is no amount of mathematical proof that you could put in front of me that would make me understand. It's not that I would doubt it, but I'd have literally nothing to say about it
Ofc, it's much clearer when Brian Cox stands on top of a glacier talking to a drone whizzing around him
 
If you slice a cube through the centre, perpendicular to the long diagonal, the cross-section is a regular hexagon. That's fairly easy to prove. In my early 20s, I proved that if you do the equivalent to a 4D hypercube, you get an octahedron. I've spent a lot of time contemplating 4D geometry, but I don't claim I can truly visualise it, although I've had momentary glimpses that were pretty convincing. :)
 
@PM2Ring I think there is an inductive solution with best-case O(N) time. I cobbled together an outline at pastebin.com/svc6RUFf.
 
@roganjosh :) Brian Cox & Brian May have done 1 show together. I reckon they could do it on a regular basis, and call it The Two Brians ;)
 
The worst case is, like... O(N*M!) where M is the number of palindrome pairs of length three or less. Or something.
It would really churn on the input "A"*100 for example
 
@PM2Ring AHA! Finally, a weak spot. Puns could take some work :P
 
3:35 PM
@PM2Ring Do you mean on Stargazing LIVE or something more recent?
 
@Kevin That looks great! Maybe I'm misunderstanding, but on line 26 you say "If these new slices do not overlap". How could they overlap? The original p & q don't overlap, p's indices are less than q's, and you reduce p's low index & increase q's high index, so the new growth is outwards, not towards each other.
@toonarmycaptain Yes. 08012013 (Stargazing LIVE), is the only thing I've found. It's on YouTube, but I haven't watched it yet.
 
I don't think it's safe to assume that P's indices are less than Q's. Consider the string "ABB", which can decompose into P = "B", Q = "AB". Increasing P's and Q's boundaries turns them into "BB" and "ABB", which causes overlap.
 
To find the sum of digits of a number I am storing digits in an array and again using a loop getting the sum.

n=input()
digs=[int(dig) for dig in str(n)]
dig_sum=0
for dig in digs:
    dig_sum+=dig


Is there any way to get the sum in the first line while getting digits? I have tried `digs=[dig_sum+=int(dig) for dig in str(n)` but that's showing error :(
 
@Kevin Oh, ok. I thought P's position was less than Q's.
 
@PM2Ring I will be taking a look.
 
3:44 PM
Hi @taritgoswami Kevin may have a much better algorithm for the palindrome puzzle. We're currently discussing it.
 
@PM2Ring Hi, Ok.
 
@taritgoswami There's a better way to do this, using Python's built-in sum function.
 
I'm not 100% convinced that the requirements as I rephrased them are the same as tarit's desired requirements. I guess I'll find out if I find the time to actually implement the outline and run it on his sample case.
 
dig_sum = sum(int(dig) for dig in str(n))
@Kevin I have a few other things I need to do first, but I'll try to code it up today, too.
 
@PM2Ring Ok, thanks
 
3:50 PM
Heck, who made slices unhashable while I wasn't looking
 
@taritgoswami You cannot do += inside a list comprehension. You can't execute statements inside a list comp, etc. You can only evaluate an expression. Python has just added a new syntax, the assignment expression, but that's just for simple assignment, you can't use it for +=.
@Kevin The scoundrels! I guess we'll have to make do with plain tuples, then.
 
@PM2Ring Yesterday I was searching for some string algos related to this problem, and I found some relted topics here, here, here. I am not able to understand those fully, probably it can help..
 
hello
 
Hi
 
@taritgoswami I'll have a look at them later, when I'm not on my phone. Finding palindrome substrings is pretty straightforward; your puzzle is much trickier because we're building palindromes from pairs of non-overlapping substrings.
 
3:58 PM
I'm having error with my django codes
src = FeatureProducts.objects.filter(status=True)
id = FeatureProducts[0].id
coupons = Coupons.objects.get(product_id=id)
 
@PM2Ring Ok
 
this: FeatureProducts[0].id throws error
 
What error?
 
Exception Type: 	TypeError
Exception Value: 	'ModelBase' object does not support indexing
 
Stuff like this keeps illustrating the divide between Flask and Django. I daren't even try suggest anything there, sorry
 
4:03 PM
arrrgghhhhh
thanks any way
 
There are Django users in this room
 
Hmm, I think there's a problem with my algorithm. In all the cases it can detect, the length of p and q differ by at most one. This means that it won't notice that the input "BCBAxyzA" can yield p="A" q="BCBA".
Maybe if I change the base case to "len(p) == 1 or len(q) == 1"... But then it becomes harder to identify base case pairs.
Basically you'd have to identify all "semi-palindromes", which are one character short of being complete palindromes.
In the best case where a string contains very few semi-palindromes, you can find them in O(N)ish time. In the worst case where there are many semi-palindromes, it's O(N^2).
 
4:22 PM
@dodge, @PaulMcG and anyone at PyTexas this weekend, I've put twitter on my phone so if you want to hit me up this weekend, I'm @toonarmycaptain there too :)
 
@toonarmycaptain See youtu.be/ODEShfdxoR0 :)
@Kevin Drats. :( But it was a good start.
@Kevin I went down the semi-palindrome rabbit-hole the other day. It got complicated...
 
Yeah, it's fiddly. I'm thinking of ways to avoid needing separate cases for left-semi-palindromes (ex BCDCBA) vs right-semi-palindromes (ex ABCDCB)
Something something "reverse the string and search again" something something
 
4:38 PM
@toonarmycaptain I'm not surprised about that calculator dependency. For a while, it was the trend in primary education in many places to not teach kids arithmetic by rote, prefering a more conceptual approach. So there's a whole generation of people that didn't memorize the multiplication tables
A decade or so ago I was amazed to learn that one of the other regulars on a science forum that I frequented needed a calculator for single digit multiplication, even though he could (allegedly) do algebra. This guy has a BSc in chemistry, and was employed as an industrial chemist.
 
@PM2Ring I'm talking 8-2, 4+5, not just times tables and fractions, which are separate (albeit serious) issues.
@PM2Ring Admittedly how often does he have to factor a quadratic....but how do you do that without basic multiplicatory number sense....??!?!
 
@toonarmycaptain Gee, you can do those on your fingers. :)
yesterday, by PM 2Ring
@taritgoswami Sorry for the huge delay. And I'm sorry to say that I didn't have much success. My theory didn't work out so well. :( Eg, if p='abb' then q can be any of {'bba', 'ba', 'a'} or s + 'bba', where s is any palindrome. I tried a few things that almost worked, but my code was getting rather messy and complicated.
 
@PM2Ring Yes, I can. And? [Apparently they cannot.]
 
@toonarmycaptain Indeed! I guess he just uses the quadratic formula, even on ones that are easy to factorise. My mental arithmetic skills aren't as sharp as they were when I was younger, but I'm still pretty good, and I can do algebra in my head, if I don't have too many things to keep track of.
 
I think I give up for today. stackoverflow.com/questions/55655010/… (deleted answer I think is visible to 10K+?).
 
4:49 PM
I impressed myself a couple of months ago, when I had a bit of insomnia, by solving the cubic x^3 = x + 1in my head. ;) But cubics are generally painful to solve, unless the coefficients are nice, since you get messy fractions, cube roots, and complex numbers, popping up.
 
@PM2Ring You give me x2 + 2x + 1 and make me use the quadratic formula, and I'm much more likely to make an error than if I do it in my head without.
 
@PM2Ring That is pretty insane
cbg
 
@toonarmycaptain Ok, I'll look for you this weekend
 
@PM2Ring What I have in mind is a little easier because in my base cases, if P is a semi-palindrome, then Q must be exactly one character long. Or vice versa.
 
@ParitoshSingh Yes, it is. :) Of course, a C compiler sold by Microsoft probably doesn't contain the Thompson Hack, but good luck proving it. Even if you had the .c source of the compiler you couldn't tell, since all of your inspection tools are compromised.
 
4:56 PM
hi, does anyone have experience with the use of Dask DataFrame?
I have a Memory Error problem with my script reading .txt files and manipulating them with Pandas
stackoverflow.com/questions/55656207/… if anyone can give a hand, I'd truly appreciate it!
 
How big is the file?
 
from 60 to 200 mb
220*
 
ugh, now we slam into the rules of the room
 
yikes, what the heck did you do with it
 
When I said filth I more just meant the fact that I don't want to subject the fine folk here to my abysmal code
 
4:59 PM
oh sorry!
I had no idea about the rules,!
sorry!!
 
No worries :) The discussion will have to continue on your post
 
ok, great, thank you and sorry again, I'm new at this! Cheers!
 
@toonarmycaptain Yep. I rarely use the quadratic formula, on principle. ;) I thought it was amazing, the first time I saw it as a kid, before I understood how it was derived. If I can't factorise a quadratic, I generally solve it by completing the square. Unless it's a ridiculously messy algebraic thing, eg where all the coefficients are trig functions.
@Phase We don't mind that, as long as you format your code. And you made some attempt to make it readable by other humans who aren't mind-readers. And you're prepared to listen to, and act on, our constructive criticism.
 
Currently waiting for the brain fog to clear so I can implement def overlaps(slice_a, slice_b):
Guess I'll go with the approach that's ten times slower but has a 90% smaller chance of having a fencepost error
 
not set(range(*slice_a.indices(a.stop))).isdisjoint(range(*slice_b.indices(b.stop)))?
 
5:12 PM
@Aran-Fey Did you have another go at this palindrome problem?
 
can I get pk of an instance in Django?
 
Nah. I was just barely bored enough to even make a first attempt, and when I realized that it's more difficult than I anticipated I moved on
 
what is that code doing? what was the goal?
 
@PEBKAC I have edited the title of the question. 750MB is not large in any sense these days
Unless it needs to run on a Pi/Arduino :)
 
@ParitoshSingh It starts here:
2 days ago, by tarit goswami
Hi, I am new to programming and have wrote a program which is taking lots of time :(

The problem is to Find the number of ways a string can be split in a non-overlapping way such that p+q is a palindrome string. Two pairs (p,q) and (p',q') are treated as different iff p is chosen from different position from p' or q is chosen from diff position of q' .
 
5:22 PM
ah i see. ish
p and q are two halves of a split? as in, p+q gives back the original string?
(probably not, cause then i guess the statement p+q is a palindrome doesnt make sense)
 
I posted a brute-force solution that I believe always gives the correct result, but it's O(n**4). :(
 
2 days ago, by tarit goswami
@PM2Ring For example, take the string abba. The possible substrings which are palindrome can be formed from the pairs (p,q) resp. : ("a", "a"), ("a", "ba"), ("a", "bba"), ("ab", "a"), ("ab", "ba"), ("abb", "a"), ("b", "b") and we get: aa, aba, abba, aba, abba, abba, bb resp.
 
Note that ("ba", "b") is not a solution.
 
sifting through i ended up reading something about roganjosh naming his coffee machine or something and now i cant get over that part.
this is funny.
 
@ParitoshSingh George, the bar code reader. Not a coffee machine.
 
5:32 PM
ah yes ofcourse, apologies to George
 
@roganjosh thank you , you're right in doing so
still I have no idea what the issue is :/
 
your data is 220mb ish total?
or each file is that much? how many such files?
 
Did you un-nest the lists?
 
I considered a concatenation approach, suggested by @Parfait
but I get an error of multiple indices
although I dropped duplicates
 
@PM2Ring Uh oh.
My implementation gives eleven solutions compared to tarit's seven. BA + B == BAB is among them.
 
5:42 PM
@Kevin Assuming that Tarit hasn't given us a bogus problem spec. ;)
 
@ParitoshSingh do you use Windows task scheduler?
 
This damn documentation is driving me insane
 
@roganjosh personally no. the generic "us in the org" im not sure.
 
But he seemed adamant that 7 is the correct solution for the test case.
 
NB: I ran into a half dozen fencepost errors despite my precautions
 
5:44 PM
mmm, ok. Thanks :)
I'm mulling over my barcode reader problem. I either have a script that runs on start-up or just host the whole thing on the PC in Stores
 
@roganjosh, I'll update the post in the next few mins to make it more clear
 
The script would have to push the barcodes to my server. But this is Windows
 
run on startup? windows has a run as a service thingy. i dont know if thats task scheduler but i dont think it was
 
Oops, some old code snuck into that pastebin. What I actually meant to post was pastebin.com/wHqR2S9z.
Now there are twelve solutions.
 
something like this can help. i dont think the tool the article used is the one i used, but i did do it in a similar way when i dabbled with services a while back
 
5:47 PM
@ParitoshSingh maybe that was the wrong way to put it. I would need some script to start watching a file and it would have to start on its own
 
sounds like you could make that work as a service no issues.
basically, make it a service, tell it to boot on startup.
its the de-facto lazy way to ensure the server always starts up for us for example. we just make services out of whatever we need to run 24/7
set them to launch on startup, and done
 
Sounds like what I need
I'd prefer my server being able to read the file but there's absolutely no way I can set that up. It's definitely gonna have to be pushed from the PC to my server
 
@PM2Ring Perhaps there is an implicit requirement that p must come before q. If I filter p-after-q results, I have seven answers: (ab, a), (ab,ba), (b,b), (a,bba), (abb,a), (a,ba), and (a,a)
This corresponds to tarit's desired output, modulo ordering.
 
^ you nailed it. i just internalized that requirement without realising i did it
 
PM tried to tell me an hour ago... I'm just stubborn I guess ;-)
 
5:54 PM
@Kevin I think so. I also suspect there's a clever algorithm that counts solutions without producing them. That's often the case in combinatoric problems. OTOH, I don't see how it could do that & guarantee that each pair is a palindrome.
 
You could probably reduce the memory footprint of my approach by yielding pairs and then throwing them away once no more inductive pairs can be derived from them. But that doesn't improve the runtime.
 
6:28 PM
I just wonder the guy who wrote the explanation of the super() function in the official website of Python... did he wrote it so that it is inhumanelly hard to understand or did he believe that this can be used as learning material by first timers?
 
He's trying his best, I'm sure. super() is just a genuinely complex topic.
 
My God it is a wired topic
 
@ExoticBirdsMerchant docs or tutorial? Former is more about exactness than ease of learning.
 
TLDR: use super().blah() to call the blah method belonging to the parent (or sometimes sibling) of the class that you're in.
 
6:34 PM
Yup i got the gist of it i just want to understand expressions like> The second use case is to support cooperative multiple inheritance in a dynamic execution environment. This use case is unique to Python and is not found in statically compiled languages or languages that only support single inheritance. This makes it possible to implement “diamond diagrams” where multiple base classes implement the same method.
 
google "diamond inheritance" if you don't understand that part
 
it is a diagram expanding and contracting in a sense
can please sbdy tell me what is the type inside of super([type[, object-or-type]])
what is this type?
it is always used like super().__init__
object-or-type? hmmmmmmmmmm LOL
 
Back in the bad old days, you would supply the current class as the first argument to super.
So instead of super().__init__ inside your Fred class, you would do super(Fred).__init__.
 
Ahaaaa and it has changed!!! See!
Where could i ever find that hihii
++ object-or-type?
please help me remove some hydralic pressure from my brain
 
@Kevin Well, that sounds promising. :) I'll take a closer look at your code later. I assume we can make it more efficient by not generating the p-after-q pairs in the first place.
 
6:40 PM
Back in the bad old days, there used to be two types of object. If you didn't inherit from the right one, then super() would require even more information to correctly construct the proxy object. In particular, you would need to pass an instance of the Fred class as the second parameter. Usually you would use self.
Or, no,
Ok. Actually I just have no idea how super() and old/new style classes worked in 2.7 and earlier.
 
so there used to exist an object and a object-or-type! if u didnt inherit from the correct type of object then Python would ask is it a type (i assume the first type of object) or a type-or-object(i assume the second more fruity type of object). The second parameter would be an instance of the class of the first type
 
Disregard pretty much everything I said
 
Okie
See what kind of tutorial is so newbie-hostile? LoleleleleLOL
Only hope this post from Golem stackoverflow.com/questions/27954695/…
 
@ExoticBirdsMerchant I see that Alexander Reynolds linked you the video of "super() considered super" a few days ago. The written version may also be helpful. It's not easy to assimilate this stuff in one go.
Mar 12 at 12:24, by PM 2Ring
@towc Please see Python’s super() considered super! by Python core developer Raymond Hettinger.
 
"so there used to exist an object and a object-or-type". Not really. The fact that two kinds of classes exist(ed) doesn't have any bearing on the fact that super's second argument is allowed to be a type or a non-type.
For the same reason that function_I_just_made_up(integer_or_string) doesn't imply that there's an object that is both an integer and a string
 
6:47 PM
aha there r two types of classes. ahhhhhhhhhaaaa nice example
 
All types are objects anyway.
>>> isinstance(int, object)
True
>>> isinstance(bool, object)
True
>>> isinstance(str, object)
True
 
@PM2Ring ill check it
oh and one type of object
and by sibling they mean a sibling of the parent class in docs
 
That doesn't sound right to me.
 
@kevin it is the answer of this stack point nr . 1 stackoverflow.com/questions/27954695/…
It is a ticked answer
@PM2Ring i tried to read this but after LoggingDict it started getting blurry 2 hours ago
 
class A:
    def zort(self):
        print("Zorting from class A")

class B(A):
    def zort(self):
        print("Zorting from class B")
        super().zort()

class C(A):
    def zort(self):
        print("Zorting from class C")
        super().zort()

class D(B,C):
    def zort(self):
        print("Zorting from class D")
        super().zort()

D().zort()

#result:
# Zorting from class D
# Zorting from class B
# Zorting from class C
# Zorting from class A
 
6:51 PM
@ExoticBirdsMerchant Seriously, don't worry about how Python 2 did this stuff, unless you're forced to work with Python 2. Or you're a language archeologist. You'll just get more confused. The structure of Python 3 is a lot cleaner.
 
Here's an example. After "Zorting from class B" prints, B.zort() calls super().zort(). The super object sees that B's sibling C is next in the MRO, so it makes super().zort() call C.zort(). C is not a sibling of B's parent. B's parent has no siblings. C is a sibling of B.
 
@PM2Ring i just oppened from a link in Documentation i have Python 3 and i am reading Class Inheritance in Docummentation @Kevin let me type it
 
You wouldn't try to learn modern English by studying the English of Shakespeare's time. It's old-fashioned, and confusing.
 
B's sibling C is next in the MRO because they both have A as parent
 
So you agree that "by sibling they mean a sibling of the parent class in docs" is not accurate?
 
6:56 PM
yes but in the definition of super there is this wired line>
Return a proxy object that delegates method calls to a parent or sibling class of type.
First line actually
super() only delegates to the parent through mro right?
 
In my example, the super() inside B delegated to B's sibling C. So no.
 
... I don't actually know how this is possible, since B knows almost nothing about classes that it doesn't inherit from. But I do know that's what it does.
 
so actually D().zort() prints Zorting from class D then super().zort()... goes to B right?
from left to right
 
Yeah.
 
7:01 PM
and then the last statement was read
why Zorting from class C?
 
user7437554
Is there any reason why Jupyter notebooks returns
 
It it up there in the tupple ok
 
user7437554
rdkit.Chem.rdchem.Mol at 0x7f560e182440
 
user7437554
instead of showing an image?
 
I don't understand what "from left to right" means in this context.
 
7:03 PM
well all are being read in python from left to right
class D(B,C):
 
so it first goes with super() to B hence Zorting from class B
and then to C
B and C are both siblings and children of A
 
Ok, yeah. B.zort executes before C.zort executes because B comes before C in D's MRO, and this is because B comes before C in D's parent list.
 
But the last line
Zorting from class A both sibling B , C have A as parent
mro will go to A to depth that depth somehow hmmmmm nasty
because its a diagram
mro will not stop until it finds the root node right?
 
I don't think the MRO algorithm uses regular old depth first search.
 
7:09 PM
its dynamic in multiple inheritance
 
Apparently python.org/download/releases/2.3/mro describes the algorithm in detail.
 
u re right
@Kevin why python 2 i use python 3 actually the python docs have this learning material available how can i know if it is of p2 or p3?
probably develop a kind of touch and understand if something is an oldie
 
AFAICT the MRO resolution system hasn't changed since Python 2.3. That document should still be good.
 
I ll check it out now but just a question: type in the super fuction is a type of class? super([type[, object-or-type]])
This sentence throws me out of balance: The search order is same as that used by getattr() except that the type itself is skipped.
i know getattr() yes but type here is a type of class right?
 
"type" and "class" are often used interchangeably in the documentation. Back in the day, the distinction between the two used to be larger and more important. In Python 3 they're nearly indistinguishable.
 
7:15 PM
Wow aha that's why earlier u typed with super (the current class) because of the differences btw classes of that time
class C(B):
def method(self, arg):
super().method(arg)
 
Not sure what you mean. My example is primarily intended for Python 3. So any information about "back in the day" doesn't really apply to it.
 
maybe this explanation of Python in docs is not good for Python3
 
Or maybe you're saying "that's why earlier you said that it was necessary to call super() with more than one argument -- because classes behaved differently back then", which is a fair assessment
 
cause it says super([type[,object-or-type]]) but if class and type are indistinguisable
exactly
class C(B):
def method(self, arg):
super().method(arg)
Type here is self which is the same in the namescope of class C the instance of C so........ type is a class! ..... by modern standards
and method(arg) probably a data reference from parent class B
 
"type here is self" doesn't sound right to me. zero-argument super() uses magic to deduce the class that's calling it. In this context, super().method(arg) is equivalent to super(C).method(arg).
self doesn't get involved at all.
Uh, I think.
 
7:22 PM
self usually gets passed to the method, right?
 
hmmm exactly u dont have to right class C in super()
right with init
__init__(self,parg,kwarg): like that
 
Or, hmm, maybe zero-argument super uses magic to deduce the class and the self object???
Have you noticed that I've contradicted myself five times in the last half hour? This is pretty good evidence that super() is a genuinely complicated topic. QED.
 
Yup we gonna crack it ... i mean the fault lines can be seen
Terminology is a little of an issue
 
I changed my mind. zero-argument super deduces both the class and the self object.
 
W8 i think the answer is here: The search order is same as that used by getattr() except that the type itself is skipped.
 
7:25 PM
But "Type here is self" is still incorrect. self is not a type. (usually.)
 
..... that the type itself is skipped
self is an instance of a class so it is not a class
that means not a type
since class=type
 
If I try to do D().derp, getattr looks for derp in the D class, in the B class, in the C class, and in the A class. When I do super(D, self).blorp(), it looks for blorp in the B class, in the C class, and in the A class. It does not look in the D class. This is how getattr and super differ: the type itself (in this case, D) is skipped.
 
yes because i can have in D an overriding blorp
yes getattr looks in the D too ... that is why i type it in the super tupple to skip it in a sence... i need to test it
 
cabbagè
 
class E:
    narf = 23
    def foo(self):
        return "foo"

class F(E):
    fran = 42
    def bar(self):
        return "bar"

x = F()
#both E and F are in getattr's search path. These will succeed.
print(getattr(x, "fran"))
print(getattr(x, "narf"))

#E is in super's search path. This will succeed.
super(F, x).foo()
#F is not in super's search path; this will fail.
super(F, x).bar()
 
7:37 PM
hmmmm
42
23
Traceback (most recent call last):
File "<pyshell#196>", line 1, in <module>
import gamikoulas
File "C:\Users\Marinaras\AppData\Local\Programs\Python\Python37\modules\gamikoulas.py", line 20, in <module>
super(F, x).bar()
AttributeError: 'super' object has no attribute 'bar'
exactly
althouth it dint print out 'foo; the error is coherent with your explanation
 
It didn't print out "foo" because I wrote super(F, x).foo() and not print(super(F, x).foo())
 
super(F, x).bar() it has no attribute bar() because bar() is defined in the namespace of F
^^ :P
 
@ExoticBirdsMerchant These days "type" is a synonym of "class", but it's often used to refer to a fundamental parent class that only has object as its parent, and which may be inherited by other classes. In Ancient Python, "type" meant a class defined in C, not Python, in other words, built-in classes like int, str, tuple, list, etc. They didn't inherit from object, and you could not create a subclass from them.
 
so i what a class with an parent object writen in C
it was built in .. think python is writen in C
@Kevin that shed a lot of light
 
I have starred that zorting comment by @Kevin, please star the comment that ends this discussion(in case i don't)...i'd later print all this 'super' nice conversation
 
7:45 PM
There is a different (but related) meaning of "type" that's connected with metaclasses, but I won't go into that, in order to avoid further confusion. ;)
 
It ll be starred sec
 
Stars are not a very good way of keeping track of conversations. Please just bookmark the permalink.
 
ok, thanks, will permalink it from next time
 
i copied it all in a word doc
 
@ExoticBirdsMerchant: I am going to do the same
 
7:48 PM
@ExoticBirdsMerchant Yes, standard Python is written in C. So it's also called CPython. In Python 3, the built-in types are still objects defined by C code, not Python code (which makes them efficient). But we can now inherit from them in a class defined by Python code.
 
Yup i ve heard that C is really scalable and that is why Python was written in C
Guys dont know about you but i feel like i whooped King Kong
....or better yet ...zorted
 
user7437554
numbers = [10, 12, 15, 18, 20]
for number in numbers:
  print(number)
 
user7437554
Is there anything wrong? It doesnt print :(
 
user7437554
(In Linux terminal)
 
I feel like the lady that painted over that hundred year old fresco with a Potato Jesus
"This job would be best handled by an expert, but all you've got is me, so..."
 
7:54 PM
Googled that
you nailed it @kevin
 
@santimirandarp Works on my machine. Are you sure you're in a REPL? Try uploading a screenshot of the terminal.
 
user7437554
I've just typed python on the terminal
 
Read Eval Print Loop. AKA an interactive prompt.
 
user7437554
it starts, and then:
 
AKA the thing that usually appears when you type "python" in a terminal
 
user7437554
7:57 PM
folder$: python
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> numbers = [10, 12, 15, 18, 20]
>>> for number in numbers:
...   print(number)
...
@Kevin
 
Try pressing Enter one more time.
 
user7437554
OH
 
user7437554
F***
 
user7437554
thanks @Kevin :)
 
7:59 PM
When a line starts with a ... that more or less means that it isn't sure whether you've finished writing the block. Two newlines in a row usually settles it.
 
user7437554
clear enough
 
Although there are some times where a newline doesn't cut it:
>>> print(
...
...
...
...
...
...
...
...
...
...
... 1)
1
 

« first day (3100 days earlier)      last day (1865 days later) »