Twitter | Pretraživanje | |
David Beazley
Sure, you could use _ as a throw-away variable in a Python for-loop. Yeah, you could definitely do that... like everyone else. Or you could just do this: >>> a = [ (0, 'Hello'), (1, 'Satan') ] >>> for {}[()], x in a: ... print(x) ... Hello Satan >>> Be different.
Reply Retweet Označi sa "sviđa mi se" More
David Beazley 26. stu
Odgovor korisniku/ci @dabeaz
You can also mix things up... >>> for {}[(),...,()], x in a: ... print(x) ... Hello Satan >>>
Reply Retweet Označi sa "sviđa mi se"
David Beazley 27. stu
Odgovor korisniku/ci @dabeaz
>>> a = [(0, 'Hello'), (1, 'Satan')] >>> for (lambda:()).foldl,x in a: ... print(x) ... Hello Satan >>>
Reply Retweet Označi sa "sviđa mi se"
David Beazley 27. stu
Odgovor korisniku/ci @dabeaz
The key to good code is for it to look impressive.
Reply Retweet Označi sa "sviđa mi se"
David Beazley 26. stu
Odgovor korisniku/ci @dabeaz
For what it's worth, if you want to write code like this, you should take my compilers course ;-). A huge discussion (and design problem) centers around the concept of lvalue and rvalue expressions in assignment operations. This is a diabolical lvalue.
Reply Retweet Označi sa "sviđa mi se"
Baptiste Mispelon 28. stu
Odgovor korisniku/ci @dabeaz
I made sg "useful" with it: ᚐ = type('ᚐ',(object,),{'ᚐ':{},'__getattr__':lambda s,a:s.ᚐ[a],'__setattr__':lambda s,a,v:s.ᚐ.__setitem__(a,s.ᚐ[a]+v)if a in s.ᚐ else s.ᚐ.__setitem__(a,v)})() for ᚐ.i, ᚐ.s in [(600, 'sa'), (60, 'ta'), (6, 'n')]: pass print(ᚐ.i, ᚐ.s)
Reply Retweet Označi sa "sviđa mi se"
Baptiste Mispelon 28. stu
Odgovor korisniku/ci @dabeaz
Non-minified source code at
Reply Retweet Označi sa "sviđa mi se"
Hazelnut 26. stu
Odgovor korisniku/ci @dabeaz
What sorcery is this?
Reply Retweet Označi sa "sviđa mi se"
David Beazley 26. stu
Odgovor korisniku/ci @HazelStones
Python.
Reply Retweet Označi sa "sviđa mi se"
Kelly Sovacool 26. stu
Odgovor korisniku/ci @dabeaz
Thanks, I hate it.
Reply Retweet Označi sa "sviđa mi se"
David Beazley 26. stu
Odgovor korisniku/ci @kelly_sovacool
It looks better from the other side of the monitor.
Reply Retweet Označi sa "sviđa mi se"