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
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
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
"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
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
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
>
> '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
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
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
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
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(
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.
12 matches
Mail list logo