News for hackers. Stuff that matters.
Re:WTFPython – Understanding Python through surprising snippets by fxj on Monday December 23, 2019 @05:09AM (#21862633)
With the new walrus operator you dont need indents anymore. You can write everything in one line in an array:

e.g.

  y=0
  for i in range(10):
      x=i+1
      y=y+x*2
      
can be written as:

  [y:=0] + [[x:=i+1, y:y+x*2] for i in range(10)]
The square brackets are the new curly brackets.
Re:WTFPython – Understanding Python through surprising snippets by joshuamorton on Monday December 23, 2019 @11:42AM (#21864827)
As others mentioned, using lambdas this has been possible for ages. There's even a too to auto convert pre walrus code to a single line.

It's just that no one does it.

Re:WTFPython – Understanding Python through surprising snippets by NotSammyHagar on Friday December 27, 2019 @03:20PM (#21894228)
That is evil and wonderful. another reason to love/hate python. I'm working on a project for fun over the holidays and of course I wrote it in python 2.7, and it needs to process unicode so I inflicted double punishment on myself ;-)

My work project just happens to use python 2.7, causing pain for everyone.