"Don't rebind built-in names*" - it confuses readers

Skip Montanaro skip at pobox.com
Wed Jun 12 20:06:08 EDT 2013


> Okay, now I'm a bit confused.  "print" is both a <keyword> and a
> member of the builtins.  What happens then?

It's a keyword in Python < 3, a built-in function in Python >= 3:

~% python3
Python 3.4.0a0 (default:96f08a22f562, Feb 24 2013, 23:37:53)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print
<built-in function print>
>>> x = print
>>>
~% python2
Python 2.7.5+ (2.7:4657d0eebe42, Jun  2 2013, 07:46:59)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print

>>> x = print
  File "<stdin>", line 1
    x = print
            ^
SyntaxError: invalid syntax


Skip



More information about the Python-list mailing list