ugly python namespace bug

Rob Hodges s323140 at student.uq.edu.au
Tue Dec 21 11:22:24 EST 1999


"Jesper Hertel" <jh at cddk.dk> writes:

> As a suggestion, maybe Python could be changed to allow for "constant"
> definitions or so. Like
> 
> const def type(..):
>     ...something...
> 
> or
> 
> const a = 2
> 
> Variables (and functions) declared like this would then have a flag telling
> that it is not allowed to change it, and an exception would be raised if
> someone tried to do it.
> 
> Built-in functions could then be declared like this. One problem by this is
> the backwards compatibility. If someone redefines built-in functions in
> existing programs, they would not be able to run these programs in new
> versions of Python.

And indeed they do all the time, because `str' is a great name for a
string, and `dir' is a great name for a directory, and `esr' is a
great name for Eric Raymond... uh, I guess he's not a built-in... you
get my drift.  

I think it would be more appropriate if you could, in each file,
optionally place a statement that tells the interpreter to treat
built-ins as keywords.  Then it would stop you dead in your tracks if
you tried to change them, without breaking any old code.  What's
another quick statement after the sh'bang and before the imports eh?

-Rob




More information about the Python-list mailing list