How to execute code when a module is imported ?
Titi Anggono
tiang_ono at yahoo.com
Mon Aug 1 20:50:26 EDT 2005
I tried
>>>foo.codetoexecwhenloaded()
and it worked
--- Arthas <arthas.thesox at gmail.com> 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
More information about the Python-list
mailing list