"Don't rebind built-in names*" - it confuses readers
Skip Montanaro
skip at pobox.com
Wed Jun 12 20:18:20 EDT 2013
>>> int="five"
>>> [int(i) for i in ["1","2","3"]]
TypeError: str is not callable
> Now how are you going to get the original int type back?
Magic. :-)
>>> int = "five"
>>> int("a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
>>> from __builtin__ import int as _int
>>> _int("5")
5
Not sure of the magic necessary in Python 3. This is definitely
something you don't want to make a habit of...
S
More information about the Python-list
mailing list