python newbie question

Diez B. Roggisch deets at nospam.web.de
Sun Feb 26 16:51:28 EST 2006


ken.carlino at gmail.com schrieb:
> I am new to python, can you please tell me how can I convert my python
> script into an executable on linux?
> i.e. instead of typing 'python myscript.py abc', I just need to do
> 'myscript.py abc'?
> and how can I get the input argument from my script , in my example,
> how can I read 'abc'?

You need a shebang on top of your script, like this:

#!/usr/bin/python


Don't forget to chmod a+x <script>

And for the args: that's sys.argv, and better even optparse.

Diez




More information about the Python-list mailing list