Asking for help with code? Post a minimal working example. (was: importing modules dynamicly)

2011-01-11 Thread Ben Finney
Jean-Michel Pichavant writes: > Your code is rather strange, 'modules' looks to be a list or some > iterable, and then you expect to have a 'modulename' attribute or > something... > My guess is that you pasted an approximative translation of your code > which makes it impossible de debug. To t

Re: importing modules dynamicly

2011-01-11 Thread Jean-Michel Pichavant
dubux wrote: I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my m

Re: importing modules dynamicly

2011-01-10 Thread Steven D'Aprano
On Mon, 10 Jan 2011 20:42:17 -0800, dubux wrote: > After loading all the modules, i try to do something like: > > instance = modules.modulename.class() No you don't. class is a reserved word in Python, you would get a SyntaxError if you did that. Please post the error you get, including the co

importing modules dynamicly

2011-01-10 Thread dubux
I am trying to import modules dynamicly from a directory (modules/) in which i have __init__.py with the __all__ variable set. Everything imports correctly and I have verified this however I am stuck on actually using my classes in the dynamicly imported modules. this bit is in my main.py (or base