[Python-Dev] Deprecating builtin id (and moving it to sys())

Guido van Rossum gvanrossum at gmail.com
Sat Aug 20 06:00:17 CEST 2005

On 8/19/05, Jeremy Hylton <jeremy at alum.mit.edu> wrote:
> On 8/18/05, Guido van Rossum <gvanrossum at gmail.com> wrote:
> > On 8/17/05, Anthony Baxter <anthony at interlink.com.au> wrote:
> > > If you _really_ want to call a local variable 'id' you can (but shouldn't).
> >
> > Disagreed. The built-in namespace is searched last for a reason -- the
> > design is such that if you don't care for a particular built-in you
> > don't need to know about it.
> In practice, it causes much confusion if you ever use a local variable
> that has the same name as the built-in namespace.  If you intend to
> use id as a variable, it leads to confusing messages when a typo or
> editing error accidentally removes the definition, because the name
> will still be defined for you.  It also leads to confusion when you
> later want to use the builtin in the same module or function (or in
> the debugger).  If Python defines the name, I don't want to provide a
> redefinition.

This has startled me a few times, but never for more than 30 seconds.

In correct code there sure isn't any confusion.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list