RIght now, I type "python myfile.py" to run it.

How can I type "py myfile.py" to run it? Or better, do this ./myfile.py?

Any tips?

link|improve this question

feedback

2 Answers

You can add this as the first line of your python script:

#!/usr/bin/env python

Which will allow you to run your script as:

./myfile.py

But you must make sure you make your python script executable:

chmod +x myfile.py
link|improve this answer
5  
And if you want to skip adding the ./ place the script somewhere in your path. For extra points rename the file and skip adding the .py extension. – Zoredache Jun 22 '10 at 23:21
feedback
alias py='python'
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.