Re: "dynamical" importing

2005-10-19 Thread Joerg Schuster
Thanks a lot to all. -- http://mail.python.org/mailman/listinfo/python-list

Re: "dynamical" importing

2005-10-19 Thread John Abel
Fredrik Lundh wrote: >John Abel wrote: > > > >>def _importModule( moduleName ): >>modName = __import__ ( moduleName ) >>modComponents = moduleName.split( '.' ) >>for indivComp in modComponents[ 1: ]: >>modName = getattr( modName, indivComp ) >> >> return modName >> >> >

Re: "dynamical" importing

2005-10-19 Thread Fredrik Lundh
John Abel wrote: > def _importModule( moduleName ): > modName = __import__ ( moduleName ) > modComponents = moduleName.split( '.' ) > for indivComp in modComponents[ 1: ]: > modName = getattr( modName, indivComp ) > >return modName __import__ takes a module name, not an ar

Re: "dynamical" importing

2005-10-19 Thread John Abel
Try: userModule = _importModule( pathToModule ) def _importModule( moduleName ): modName = __import__ ( moduleName ) modComponents = moduleName.split( '.' ) for indivComp in modComponents[ 1: ]: modName = getattr( modName, indivComp ) return modName HTH, J Joerg Schust

Re: "dynamical" importing

2005-10-19 Thread Fredrik Lundh
Joerg Schuster wrote: > I need to import modules from user defined paths. I.e. I want to do > something like: > > module_dir = sys.argv[1] > > my_path = os.path.join(module_dir, 'bin', 'my_module') > > from my_path import my_object > > Obviously, it doesn't work this way. How would it work? some

Re: "dynamical" importing

2005-10-19 Thread Laurent Rahuel
Hi, I guess you need to look at __import__ Regards, Laurent. Joerg Schuster wrote: > Hello, > > I need to import modules from user defined paths. I.e. I want to do > something > like: > > module_dir = sys.argv[1] > > my_path = os.path.join(module_dir, 'bin', 'my_module') > > from my_path i

"dynamical" importing

2005-10-19 Thread Joerg Schuster
Hello, I need to import modules from user defined paths. I.e. I want to do something like: module_dir = sys.argv[1] my_path = os.path.join(module_dir, 'bin', 'my_module') from my_path import my_object Obviously, it doesn't work this way. How would it work? Jörg Schuster -- http://mail.pytho