Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One of my favorite tomfooleries in Python is this:

>>> True, False = False, True

It doesn't have much practical effect, since most logical tests don't use the True and False constants directly. But it's a good way to perplex the unwary.



In Python 3.x, this gives me a "SyntaxError: assignment to keyword" error.


They changed the language definition for Python 3 to make True and False keywords, unlike in previous versions.


import random

if random.randint(0,1): (True,False) = (False,True)


(Some dialects of) Smalltalk had `true become: false`, which not only changed the names of `true` and `false`, but also all references to `true` are replaced with references to `false`


rev_null, you are dead. Make a new account.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: