I can also do this, which is harmful. >>> True = False >>> False = True
Python bug: Can assign [] = (), but not () = []
11–20 of 53 posts
Re: Python bug: Can assign [] = (), but not () = []
#12I can also do this, which is harmful. >>> True = False >>> False = True
You could write (False, True) = (True, False) though.
Re: Python bug: Can assign [] = (), but not () = []
#13I can also do this, which is harmful. >>> True = False >>> False = True
Re: Python bug: Can assign [] = (), but not () = []
#14Re: Python bug: Can assign [] = (), but not () = []
#15Re: Python bug: Can assign [] = (), but not () = []
#16>>> (a, b) = 2, 3
>>> {a, b} = 2, 3
File "", line 1
SyntaxError: can't assign to literalRe: Python bug: Can assign [] = (), but not () = []
#17Earlier quoted context omitted.
As an occasional numpy contributor, I would call this a bug.
Good point - I found it after it caused a really weird bug in a library I use. I'll open an issue on github...
>>> import warnings
>>> warnings.simplefilter('always')
>>> 'x'*np.float64(3.5)
__main__:1: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
'xxx'Re: Python bug: Can assign [] = (), but not () = []
#18This is a fun numpy quirk: >>> 'x'*3.5 Traceback (most recent call last): File " ", line 1, in TypeError: can't multiply sequence by non-int of type 'float' >>> import numpy as np >>> print 'x'*np.float64(3.5) xxx
As an occasional numpy contributor, I would call this a bug.
Re: Python bug: Can assign [] = (), but not () = []
#19Earlier quoted context omitted.
Python 3 removed this feature unfortunately.
>>> (False, True) = (True, False) >>> 1 if False else 0 1 >>> bool(0) == False False
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> (True, False) = (False, True)
File "", line 1
SyntaxError: can't assign to keywordRe: Python bug: Can assign [] = (), but not () = []
#20Earlier quoted context omitted.
Python 3 removed this feature unfortunately.
>>> (False, True) = (True, False) >>> 1 if False else 0 1 >>> bool(0) == False False
>>> (False, True) = (True, False)
File "", line 1
SyntaxError: can't assign to keyword