Alric Aneron schrieb:
I see I can only execute python functions in external methods.
Is there any way to execute the whole file, not just a certain function? In linux I created a python script, and it doesn't have functions. I just want to execute the whole file. I tried using "self" or "init" for function names in Zope and it doesn't want to do it, telling me "The specified object, /init/, was not found in module, /test/."

Is there a way to execute a file?

Yes, you can use os.popen* for example - but what is the point?
You would waste memory and CPU cycles in firing another complete
interpreter environment.

Instead move the commands in the "file" into a function, use
the common pattern:

def main():

if __name__=='__main__':

As you see in many modules.

This was you just import the "file" as module in your external method
and call yourmodule.main()

(another question: is there a way to execute bash commands in linux? or is external methods only good for python?)

What are bash commands? Builtin commands like if, fi, while, case etc?
Or do you mean just external executables (binaries, scripts)?
And if so, what are they fore? Python is very capable and you can do
most with it as easy/easier then with extra commands.
If not, see above for os.popen and friends.

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to