Re: Find the location of a loaded module

2009-02-22 Thread Pekka Klärck
2009/2/21 Gabriel Genellina : > > Use packages. Make act1 and act2 packages by creating __init__.py files. That's how I'd do it too. The code would be also more easy to understand and maintain: import act1 import act2 act1.story() act2.story() Alternative solution would be using reload functio

Re: Find the location of a loaded module

2009-02-22 Thread Steve Holden
Gabriel Genellina wrote: > En Sat, 21 Feb 2009 14:51:40 -0200, escribió: > >> "Gabriel Genellina" wrote: >>> En Fri, 20 Feb 2009 20:44:21 -0200, Aaron Scott >>> escribi=F3: >>> >>> > So, the problem lies with how Python cached the modules in memory. >>> > Yes, the modules were in two different

Re: Find the location of a loaded module

2009-02-21 Thread Gabriel Genellina
En Sat, 21 Feb 2009 14:51:40 -0200, escribió: "Gabriel Genellina" wrote: En Fri, 20 Feb 2009 20:44:21 -0200, Aaron Scott escribi=F3: > So, the problem lies with how Python cached the modules in memory. > Yes, the modules were in two different locations and yes, the one that > I specified us

Re: Find the location of a loaded module

2009-02-21 Thread rdmurray
"Gabriel Genellina" wrote: > En Fri, 20 Feb 2009 20:44:21 -0200, Aaron Scott > escribi=F3: > > > So, the problem lies with how Python cached the modules in memory. > > Yes, the modules were in two different locations and yes, the one that > > I specified using its direct path should be the one l

Re: Find the location of a loaded module

2009-02-20 Thread Gabriel Genellina
En Fri, 20 Feb 2009 20:44:21 -0200, Aaron Scott escribió: So, the problem lies with how Python cached the modules in memory. Yes, the modules were in two different locations and yes, the one that I specified using its direct path should be the one loaded. The problem is, the module isn't alwa

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
And finally, an epilogue. So, the problem lies with how Python cached the modules in memory. Yes, the modules were in two different locations and yes, the one that I specified using its direct path should be the one loaded. The problem is, the module isn't always loaded -- if it's already in memor

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
> > 'req.write(story.game.Save())' returns '/home/www/--/docs/act2/ > storylab/game.pyc' as the file being accessed. > Sorry, that should have read: > 'req.write(story.game.Save())' returns > '/home/www/--/docs/act2/story/game.pyc' as the file being accessed. -- http://mail.python.org/mailman/lis

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
Son of a bitch. It gets worse. > Executed from inside 'act1', which contains the directory / module > 'story': > >         directory = os.path.dirname(__file__) >         req.write(str(directory)) >         story = apache.import_module('story', path=[directory]) > > Results: > > /home/www/---/do

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
And more madness... Executed from inside 'act1', which contains the directory / module 'story': directory = os.path.dirname(__file__) req.write(str(directory)) story = apache.import_module('story', path=[directory]) Results: File "/home/www/---/docs/act1/play.py", l

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
Here's another clue: if I'm trying to run the script from the directory 'act1', but it's loading the module from 'act2', if I rename the module directory in 'act2' and refresh, the module still reports that it's running from '/home/www/---/docs/act2/story/game.pyc'... even though that files no long

Re: Find the location of a loaded module

2009-02-20 Thread Aaron Scott
Okay, I'm going out of my mind. I have three directories -- 'act1', 'act2', and 'act3'. Each of these has a module named 'story'. Through mod_python, I need to load 'story' in the directory 'act1'. I do it like this: req.content_type = "text/html" sys.path.append(os.path.dirname(

Re: Find the location of a loaded module

2009-02-20 Thread Christian Heimes
Aaron Scott schrieb: > I'm running into a problem that's rapidly reaching keyboard-smashing > levels. I'm trying to import a module into Python, but it seems like > Python is almost randomly loading the module from an entirely > different directory, one that shouldn't be in the module search path.