Python Oddity - print a reserved name

Diez B. Roggisch deetsNOSPAM at
Wed Sep 15 23:09:22 CEST 2004

Michael Foord wrote:
> Right - but although 'print' is a reserved word there is no *need* for
> object.print to be reserved.. and as Alex has pointed out that could
> actually be damned inconvenient..........

I tried to explain my views on that before:

The key issue is, that while

>>> def foo():
>>>    pass
>>> print foo
<function foo at 0x401eab1c>

is ok, 

>>> def print(): pass
fails here, but if not
>>> print print

can't possibly made working without unclear context-driven hacks.

And if on "normal" function level this can't be allowed, IMHO  for the sake
of consistency class methods should also not allow that - because then the
different behaviour causes confusion...

Diez B. Roggisch

More information about the Python-list mailing list