Re: Parametrized module import
From: george young (gry_at_ll.mit.edu)
Date: 07/08/04
- Next message: Markus Elfring: "Re: Matching of optional parts in regular expressions"
- Previous message: Istvan Albert: "Re: Porting Java web application to Python to make it faster?"
- In reply to: Jacek Generowicz: "Parametrized module import"
- Next in thread: Jacek Generowicz: "Re: Parametrized module import"
- Reply: Jacek Generowicz: "Re: Parametrized module import"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 8 Jul 2004 10:01:21 -0400
On 08 Jul 2004 09:43:31 +0200
Jacek Generowicz <jacek.generowicz@cern.ch> threw this fish to the penguins:
> I have a module whose behaviour needs to be configurable. The module
> needs to decide, the first time it is imported, beteween alternative
> interfaces it presents.
>
> Currently, I set some environment variables which select the desired
> behaviour, and the module inspects those variables to determine the
> mode in which it should set itself up. I would prefer a pure Python
> solution, rather than one which depends on external state.
>
> Can you recommend any approaches, or warn against the pitfalls of some
> approaches?
You might look at the way pygtk does it. I haven't peeked inside, but the
api is:
import pygtk
pygtk.require('2.0') # or '1.2' or some other version
import gtk # uses state set by require() to load the appropriate version
The pygtk.py file looks quite reusable with hardly any change...
See: http://www.pygtk.org
-- George
-- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL)
- Next message: Markus Elfring: "Re: Matching of optional parts in regular expressions"
- Previous message: Istvan Albert: "Re: Porting Java web application to Python to make it faster?"
- In reply to: Jacek Generowicz: "Parametrized module import"
- Next in thread: Jacek Generowicz: "Re: Parametrized module import"
- Reply: Jacek Generowicz: "Re: Parametrized module import"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|