On Thu, Jan 15, 2009 at 2:35 PM, Markus Schreyer <markus.schre...@gmail.com> wrote: > Hi, > we embedded python into our application via Swig. Now we like to wrap the > raw API functionality into a nicer more handleable module, but instead of > repeating every function in this wrapper i thought about importing them into > the namespace of the wrapper module. I like to give you an example of what > we like to achive. > Swig generates a file called "ppms.py" which contains the API classes and > functions. > Lets say the ppms.py contains a function called foo(). The wrapper.py should > now import the function foo() of the module ppms into the local namespace. > the swig module: > def foo(): > pass > def foo0(): > pass > One possibility would be to repeat the function in the wrapper.py like: > import ppms.py > def foo(): > return ppms.foo() > def foo0(): > return ppms.foo0()+1 > Imho this is a little ugly. So I thought about importing the content of > ppms.py (the autgenerated one) into the namespace of the wrapper. Every > definition of a fuction in the wrapper should overwrite the function in the > imported module but a call to a function which is not defined in the wrapper > goes right through. > # wrapper.py - magic version > "magic_import" ppms.py
I believe the magic you seek is: from ppms import * Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list