4 ms·
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
by aaronharnly 13y ago
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.
- dorkrawk 13y agoimport random if random.randint(0,1): (True,False) = (False,True)
- wicknicks 13y agoIn Python 3.x, this gives me a "SyntaxError: assignment to keyword" error.
- bluewres 13y agoThey changed the language definition for Python 3 to make True and False keywords, unlike in previous versions.
- rev_null 13y agoI once put this into my ipython configuration and later discovered that I couldn't exit because of it.
- Tomis02 13y agorev_null, you are dead. Make a new account.
- taejo 13y ago(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`