interface like behavior for mudules

P

paolo_veronelli

Hello pyple,

I have two modules :remote.py and local.py which have some classes with
the same names specifically one we can call Model.So it exist
remote.Model class and local.Model class

A third module called uri.py derives some of its classes from a not
better specified repository.Model

at the beginning of uri.py I can write 'import local as repository' or
'import remote as repository'. In either cases the module uri is ready
to be imported from a fourth module

Now I have two applications ,say applocal.py and appremote.py. Both
import uri as a module ,but the first wants uri to have imported local
as repository and the second wants uri to have imported remote as
repository.

In pseudo language applocal.py would have 'import uri with local as
repository' at the beginning and appremote.py would have 'import uri
with remote as repository'

I wonder if there is a way to keep uri unique,because as it is now I
have to keep two modules,say urilocal and uriremote which differs only
for a line at the top.

I suppose __import__ is there to help me, but I have no idea on how.

Hope I have been clear,thanks for considerations and help

Yours Paolino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top