Call variable as a function

2005-03-03 Thread Chmouel Boudjnah
Hey,
It's look simple for most of the people here but i can't figure out to that.
If i have :
def test():
print "foo"
and:
var = "test"
how do i call function test from var, kind of ${$var} in some others 
languages (or eval())

Cheers, Chmouel.
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie, help with pythonpath

2005-03-03 Thread Chmouel Boudjnah
Eduardo Suarez wrote:
I'm trying to set the python path variable so i can use them, but i 
haven't got it. Any hint?
sys.path.append('/usr/blah/blah/blah/directory')
--
http://mail.python.org/mailman/listinfo/python-list


Unimport module

2005-03-13 Thread Chmouel Boudjnah
Hi,
I have some code like that to do kind of plugins load :
dir = listdir('/path/')
for i in dir:
sys.path.append('/path/' + i "/")
import Module
doStuff()
sys.path.remove('/path/' + i "/")
it's obviously not working since it get only the first import Module 
while the others doent get replaced, the only solution for me was too :

sys.modules.pop('Module')
which after it does works fine. But my question is what's happenning in 
the internals, does it free the memory of Module to do a sys.modules.pop ?

Cheers, Chmouel.
PS: Please Mail-Copy-To: i am not subscribed to the list
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unimport module

2005-03-13 Thread Chmouel Boudjnah

Terry Reedy wrote:
Yes, Python's import mechanism assumes that sys.path is relatively static, 
or grow only.  I not sure what 'reload Module' would do after the first 
loop.
it does work using like that :
if sys.modules.has_key("Module"):
reload(Module)
else:
import Module
i think it's kind of cleaner solution.
which after it does works fine. But my question is what's happenning in 
the internals, does it free the memory of Module to do a sys.modules.pop 
A Python implementation *may* 'free' an object anytime after the last 
reference to the object disappears.  Whether the name Module and the slot 
in sys.modules are the only two references depends, I believe, on both the 
code in the module and the code the uses it.  sys.getrefcount() can help 
answer this.
ah ok, thanks to make this thing clear, do you have any pointer how to 
debug/watch the python internals ?

Cheers, Chmouel.
--
Chmouel Boudjnah -- Squiz.net -- http://www.squiz.net/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with running external process

2006-01-20 Thread Chmouel Boudjnah
see the help for ulimit (builtils) :

-$ help limit

-- 
http://mail.python.org/mailman/listinfo/python-list