[Python-ideas] keywording prohibited
Stephen J. Turnbull
stephen at xemacs.org
Sun May 3 07:45:08 CEST 2009
spir writes:
> Depends on your pov. I consider the _possibility_ of using 'list',
> 'range' or 'type' as a name for totally custom thing, without even
> a warning, an issue, not a wishable feature. It _invents_ very hard
> to diagnose bugs.
If you want warnings, use pylint. It catches all of those.
On the other hand, Python's even-handed treatment of builtins,
standard library identifiers, and user-defined identifiers makes for a
great simplification in the rules for the language, and allows for
introspective usage:
# Here's something you can do for fun on a lazy Sunday afternoon.
the_artist_formerly_known_as_list = list
def list(thing):
print "Somebody called list!"
return the_artist_formerly_known_as_list(thing)
For most of us, the gain in simplicity and power is well worth the pain.
> Strangely enough, I cannot imagine a use case for 'for' or 'in' or
> 'while' as names. while these ones are protected (indeed, I don't
> mean they shouldn't).
Dunno about the other two, but in C I used to use the equivalent of
in = open("mind", "r")
text = in.readlines()
all the time.
More information about the Python-ideas
mailing list