Lament: Import is not very smart.

Lonnie Princehouse finite.automaton at gmail.com
Wed Jul 14 16:47:56 EDT 2004


Steve <lonetwin at gmail.com> wrote in message 
> This might seem like a problem in this specific case, for this
> specific problem, but consider this:
> 
> >>> import foo.commonlib
> >>> import commonlib
> 
> where commonlib is a module I happened to write before I knew that
> foo.commonlib existed (which does something entirely different but is
> coincidently named in the similar manner.)
> 
> I'd be *very* grateful if 
> >>> foo.commonlib != commonlib

I'm advocating checking the absolute filepath first, such that:

>> import foo.commonlib
>> import commonlib
>> foo.commonlib == commonlib

...would be True iff commonlib.py is in the foo package's directory
(hence is rightfully part of the foo package).



More information about the Python-list mailing list