Parametrized module import

Jacek Generowicz jacek.generowicz at cern.ch
Fri Jul 9 09:13:39 CEST 2004


Oliver Fromme <olli at haluter.fromme.com> writes:

>  > I guess the imported module could block further configuration
>  > changes, and the warning can come when you try to change the
>  > configuration _after_ the first import.

>     #---  File config.py:  ---
>     foo_interface_mode = 0      # default
>     def set_foo_interface_mode (mode):
>         foo_interface_mode = mode
> 
>     #---  File your_module.py:  ---
>     import config
> 
>     def config_warn():
>         print "foo_interface_mode may only be set once!"
> 
>     config.set_foo_interface_mode = config_warn

Yup, that's exactly the sort of thing I was suggesting.



More information about the Python-list mailing list