>>> True = False
>>> False = True(https://gist.github.com/Jach/1208215 works in Python 3 too.)
You could write (False, True) = (True, False) though.
>>> 1 if False else 0
1
>>> bool(0) == False
False
I got stuck for a while trying to back out. Finally figured the way to reverse is to use del(): del(True) del(False).
>>> 'x'*3.5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't multiply sequence by non-int of type 'float'
>>> import numpy as np
>>> print 'x'*np.float64(3.5)
xxxIs this behavior because numpy overloads the multiplication operation with a string as string repetition and then implicitly casts the float64 down to an integer of 3? I'm curious why this behavior manifests. When I get a chance I'll test 'xyz'*np.float(3.5)
>>> "x" * 3
xxx
The only weird part (and it's not that weird IMO) is that numpy's "float" can be implicitly coerced to integer.Perhaps based on older versions of PHP or merely uninformed snark?
>>> (a, b) = 2, 3
>>> {a, b} = 2, 3
File "<interactive input>", line 1
SyntaxError: can't assign to literal>>> a, b, c, d = {1, 2, 3, 'a'}
>>> a
'a'
Regardless, it shouldn't be surprising when writing insane code, that the language starts acting insane. Python as a whole is pretty decent when it comes to handling syntactic edge cases.
stuff = ()
print(type(stuff))
<class 'tuple'>
[] = (); VM105:2 Uncaught ReferenceError: Invalid left-hand side in assignment
() = []; VM114:2 Uncaught SyntaxError: Unexpected token )