importing symbols from module objects

Paul Rubin phr-n2001 at nightsong.com
Tue Sep 25 23:21:54 EDT 2001


"Sean 'Shaleh' Perry" <shalehperry at home.com> writes:
> when you try to get around the language, "weird" calls is all you have.  You
> example may not truly reflect what you are trying to do because:
> 
> from EggsBaconSpam import breakfast, SpamException
> 
> gives you what you want and has only the one line to change.

There's lots of different classes in EggsBaconSpam.py.  I don't
want to import all its symbols into the caller's namespace--just
a few of them.  The other ones, I want to refer to as provider.symbolname.

> In some of my own code I have:
> 
> d = {}
> exec open(py) in d
> self.unpack.register(d['filetype'], d['unpack'])

I guess I don't mind such weirdness in the EggsBaconSpam module but 
I'd like to keep the caller's interface clean.  

Got any alternative suggestions for implementing service providers?



More information about the Python-list mailing list