I tried
>>>foo.codetoexecwhenloaded()
and it worked

--- Arthas <[EMAIL PROTECTED]> wrote:
> How I do it?
> 
> I wanna execute some code when a module is imported:
> 
> -- foo.py --
> #!/usr/bin/env python
> 
> def codetoexecwhenloaded():
> print "bar"
> -- end of foo.py --
> 
> -- in console --
> 
> import foo
> 
> ^ and then it should print "bar"
> 
> Thanks, Arthas
> > -- 
> http://mail.python.org/mailman/listinfo/python-list



                
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to