Re: importing / loading a module / class dynamically

2007-01-05 Thread laurent rahuel
Hi, Using exec or eval ISN'T what should be done ever. When you have troubles importing you should : - Add some repository to your sys.path and/or - Use the buildin import method and/or - Use Mr Eby's Importing module (http://python.org/pypi/Importing) Regards, Laurent hg a écrit : > Hi, > >

Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
Laszlo Nagy wrote: > >> Thanks, >> >> What I am doing is adding plugin support to PyCrust ... so I'm looking >> for a mechanism where anyone can develop a plugin and have it loaded by >> pycrust. >> >> the .py was a typo >> >> >> why the "...Have at least an empty plugin/name1/__init__.py file...

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
> Thanks, > > What I am doing is adding plugin support to PyCrust ... so I'm looking for a > mechanism where anyone can develop a plugin and have it loaded by pycrust. > > the .py was a typo > > > why the "...Have at least an empty plugin/name1/__init__.py file..." ? > When you do import plug

Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
Laszlo Nagy wrote: > >> .../.../../plugin/name1/name1.py >> >> .../.../../plugin/namen/namen.py >> >> >> I block at the beginning and tried this (test.py is a real file) >> > s = 'test.py' > eval ('import ' + s) > > import test.py # This is invalid > import test # Th

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
hg írta: > hg wrote: > > >> Hi, >> >> I have the following problem. >> >> I find in a directory hierarchy some files following a certain sets of >> rules: >> >> .../.../../plugin/name1/name1.py >> >> .../.../../plugin/namen/namen.py >> >> each file will in turn have a class with the same na

Re: importing / loading a module / class dynamically

2007-01-05 Thread hg
hg wrote: > Hi, > > I have the following problem. > > I find in a directory hierarchy some files following a certain sets of > rules: > > .../.../../plugin/name1/name1.py > > .../.../../plugin/namen/namen.py > > each file will in turn have a class with the same name as the filename > (min

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
> .../.../../plugin/name1/name1.py > > .../.../../plugin/namen/namen.py > > > I block at the beginning and tried this (test.py is a real file) > s = 'test.py' eval ('import ' + s) import test.py # This is invalid import test # This MAY be valid import name1.name1 #

importing / loading a module / class dynamically

2007-01-05 Thread hg
Hi, I have the following problem. I find in a directory hierarchy some files following a certain sets of rules: .../.../../plugin/name1/name1.py .../.../../plugin/namen/namen.py each file will in turn have a class with the same name as the filename (minus .py) I fetch those names in a li