>>>>> "Stefano" <[email protected]> (S) wrote:
>S> I have a script like this
>S> myscript.py
>S> def func01()
>S> def func02()
>S> def func03()
>S> ....
>S> def funcnn()
>S> How can i execute my func in the code ?
>S> import myscript
>S> for i in range(1,n):
>S> myscript.func??
Others have suggested getattr. I think a cleaner (more pythonic) way
would be:
funclist = [func01, func02, func03, ... ]
for i in range(1,n):
funclist[i]()
Or myscript.funclist[i]() from another module.
--
Piet van Oostrum <[email protected]>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: [email protected]
--
http://mail.python.org/mailman/listinfo/python-list