[Python-Dev] quick poll: could int, str, tuple etc. become type objects?

Guido van Rossum guido@digicool.com
Tue, 05 Jun 2001 15:56:05 -0400

> >>>>> "GvR" == Guido van Rossum <guido@digicool.com> writes:
>     >> I'm a little concerned about this, since the names that would
>     >> be added are probably in common use as variable and/or argument
>     >> names.  I.e. At one point `list' was a very common identifier
>     >> in Mailman, and I'm sure `dict' is used quite often still.  I
>     >> guess this would be okay as long as working code doesn't break
>     >> because of it.
>     GvR> It would be hard to see how this would break code, since
>     GvR> built-ins are searched *after* all variables that the user
>     GvR> defines.
> Wasn't there talk about issuing warnings for locals shadowing
> built-ins (or was that globals?).  If not, fergitaboutit.  If so, that
> would fall under the category of "breaking".
> -Barry

You may be thinking of this:

    >>> def f(int):
	     def g(): int

    <stdin>:1: SyntaxWarning: local name 'int' in 'f' shadows use of
    'int' as global in nested scope 'g'

This warns you when you override a built-in or global *and* you use
that same name in a nested function.  This code will mean something
different in 2.2 anyway (g's reference to int will become a reference
to f's int because of nested scopes).

But this does not cause a warning:

    >>> def g():
        int = 12


Nor does this:

    >>> int = 12

So we're safe.

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