importing two modules with the same name

Francisco Borges borges at let.rug.nl
Sat Mar 19 13:50:47 EST 2005


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??

---------

Before you start calling me stupid... the reason I would like that is
that:

I have a module that produces shell completion code from optparse
objects for zsh, tcsh and (sort of) bash. But to use it, I have to
directly modify the python code. Which I don't want that since I want to
be able to generate completion automatically for code which is not mine
in an easy manner.

So a shell script sets the PYTHONPATH in a way that "my optparse" is
loaded, but to build the option parser I want to then import the
original optparse module from my optparse.py file.

I could simply copy optparse's code and hack it or I could simply import
it and overload some methods, which is what I think would be a cleaner
solution.

Cheers,
-- 
Francisco.
Groningen, Nederlands.
          __o
         `\<,
  _____(*)/(*)_____




More information about the Python-list mailing list