[Python-Dev] PEP 294: Type Names in the types Module

Aahz aahz@pythoncraft.com
Tue, 25 Jun 2002 10:53:57 -0400


On Tue, Jun 25, 2002, Skip Montanaro wrote:
> 
>     >> If in 2004 certain Python programs written in 2000 or earlier would
>     >> start raising ImportError exceptions on 'from types import *' after
>     >> upgrading to a new system which may come with the latest version of
>     >> Python, this will certainly cause damage.
> 
>     aahz> This can be solved by a combination of changing the documentation
>     aahz> and using __all__ (which I think is in part precisely the point of
>     aahz> creating __all__). 
> 
> I don't think __all__ would help here.  The problem as I see it is that the
> docs say "from types import *" is safe.  If you add new names to the types
> module, they would presumably be added to __all__ as well, and then "from
> types import *" could clobber local variables or hide globals or builtins
> the programmer didn't anticipate.

The point is that we could change the docs -- but Peter would still have
his problem with import * unless we also used __all__ to retain the old
behavior.  Overall, I agree with your point about upgrading applications
four years old; I'm just suggesting a possible mechanism for minimizing
damage.
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/