importing two modules with the same name

Tim Jarman tmj at SPAMLESSjarmania.com
Sat Mar 19 15:23:04 EST 2005


Francisco Borges wrote:

> Hello,
> 
> This is not stricly necessary but it would be nice if I could get it
> done. Here is what I want to do:
> 
> There are 2 "foo" named modules, 'std foo' and 'my foo'. I want to be
> able to import 'my foo' and then from within my foo, import 'std
> foo'. Anyone can help??
> 

If I had to do this, I'd use packages:

import foo       # the standard module - presumably already on sys.path
import my.foo    # my module which lives in its own little world

Remember to qualify names correctly, and/or do something like:

import foo as std_foo

But if your foo is under your control, why not do everyone a favour and call
it something else?

-- 
Website: www DOT jarmania FULLSTOP com



More information about the Python-list mailing list