Python Oddity - print a reserved name

Diez B. Roggisch deetsNOSPAM at web.de
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:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&threadm=cacto9%24ql8%2403%241%40news.t-online.com&rnum=4&prev=/groups%3Fq%3Ddiez%2Broggisch%2Bfoo%26hl%3Den%26lr%3D%26ie%3DUTF-8%26c2coff%3D1%26selm%3Dcacto9%2524ql8%252403%25241%2540news.t-online.com%26rnum%3D4

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...
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list