[Python-Dev] Advice in stat.py

Aahz Maruch aahz@rahul.net
Sun, 29 Jul 2001 19:51:47 -0700 (PDT)


Guido van Rossum wrote:
>Greg Ward:
>> 
>> Suggested usage: from stat import *
>> 
>> Is ths still the suggested usage?
> 
> I don't see why not.

Here's why not:

from stat import *
from threading import *   # Look at the docs if you don't believe me
from Tkinter import *
from types import *

If you have a single module that imports all four of these (and I don't
think that's particularly bizarre), tracing back any random symbol to
its source becomes an annoying trek through *five* modules.  There are
probably a few other modules I don't know about that are declared "safe"
for import *.  IMO, this quickly leads to disaster, particularly when
trying to debug someone else's code (and I've wasted more time than I'd
like over this).  

It just plain goes against "explicit is better than implicit".  I think
we should declare a universal policy of NEVER recommending import *,
except for interactive use.
-- 
                      --- Aahz (@pobox.com)

Hugs and backrubs -- I break Rule 6       <*>       http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista

I don't really mind a person having the last whine, but I do mind someone 
else having the last self-righteous whine.