How to pass parameter when importing a module?

Serge Orlov Serge.Orlov at gmail.com
Sun Mar 20 14:45:12 EST 2005


Bo Peng wrote:
> Dear list,
>
> What I would like to do is something like:
>
> In myModule.py ( a wrapper module for different versions of the
> module),
>   if lib == 'standard':
>     from myModule_std import *
>   elsif lib == 'optimized'
>     from myModule_op import *
>
> but I do not know how to pass variable lib to myModule.py to achieve
> the following effect:
>
>   >>> lib = 'standard'
>   >>> from myModule import *     # actually import myModule_std

[snip]

Take a look at wxPython versioning:
http://wiki.wxpython.org/index.cgi/MultiVersionInstalls

The most simple usage looks like

      import wxversion
      wxversion.select("2.4")
      import wx
  Serge. 





More information about the Python-list mailing list