« first day (1935 days earlier)      last day (1308 days later) » 

11:41 AM
@AndrasDeak are you familiar with the chained a=b=1 assignment in python?
I'm asking because I was trying to look it up in the documentation, but it is never mentioned, and it even seems that is not defined - at least that is the point where I'm not sure.
at least here the "=" symbol only appears in assignment_stmt. So to have multiple "=" in the same statement it seems that assignment_stmt should have to appear somewhere in target_list or starred_expression or yield_expression, but if you recursively follow these definitions you never end up in assignment_stmt or any other thing that contains an "=" symbol.
 
11:57 AM
@flawr yup
the + in (target_list "=")+ means "at least once"
and the second sentence after that grammar box specifies evaluation
> An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right.
so a = b = expr is equivalent to tmp = expr; a = tmp; b = tmp; del tmp
hence a = a[0] = [[]]
 
@AndrasDeak ooh the + it is!
thanks!
 
And a related hack is stuff like for d[0] in d: pass
"Hack" as in "silly interview question"
 
@AndrasDeak I like that:)
@AndrasDeak the thing that prompted it was actually this here: stackoverflow.com/a/64397718/2913106
would you maybe mind sharing your explanation there?:)
 
@flawr meh
it has to be a dupe :P
note that it's not "chaining", because if it were chaining like a == b == c then it would even work, sort of
@flawr you forgot to mention that they should just use two lines
 
12:14 PM
@AndrasDeak I don't want to be held responsible for good coding practices!
 
And what you suggested is a good example of why I hate asspressions
Zero benefit at the price of unreadable spaghetti code
 
I disagree, the benefit is less lines!
You can save so much more paper when printing your code to file it away if you are careful with your usage of line breaks!
languages must be abused and tortured, lest they stop fearing you
 
yeah, but people read SO
 
just found another nice one: i = a[i] = 3 :)
I added a preface to my answer to say don't
 
12:31 PM
better :P
 
 
11 hours later…
11:58 PM
@flawr “they” is the poor programmers that have to work with you? :)
 

« first day (1935 days earlier)      last day (1308 days later) »