Call a Python file with parameters
ulope at gmx.de
Mon Jun 9 17:24:48 CEST 2003
"martin z" <pxtl at hotmail.com> schrieb im Newsbeitrag
news:Dr1Fa.38532$j9%.18920 at news04.bloor.is.net.cable.rogers.com...
> I've asked this before, but last time I was too vague. So, I've got a
> simpler request: I want to write and call Python files as if they were
> functions. The problem is simple: if you write a Python file with only a
> def-statement, you don't get a file you can run with arguments - you get a
> file that builds a function. If you use the argc and argv syntax, you get
> file you can run with arguments, but the arguments are strings.
> I want to have a Python file that, when I compile it, I get nothing but a
> function, or something I can use like a function, that I can shove a
> parameter tuple into. Instead I get a code object (no argument tuple) or
> module (containing functions).
# cat func.py
def somefunc(blah1, blah2):
return (blah1, blah2)
# cat prog.py
More information about the Python-list