Watch the video here https://www.youtube.com/watch?v=5CMmjNt_p48
Steps to follow to run your python code without typing python filename.py.
You can simply run by typing filename if you follow these simple steps.
#!/usr/bin/python3
This line tells about the location of interpreter.
If you are using another version of python, find that interpreter and type it in here. (I am having two version of python, python 2.7 and python 3.5 and to run it with python3 interpreter we have to type in /usr/bin/python3)
If you are using virtualenv, you can simply modify the shebang line to your interpreter.
In terminal, go to your directory where your python file is located and type the below command.
chmod +x filename.py
For example we have hello.py as our file, so we will move to the directory where it is located and will do
chmod +x hello.py
Now you can run your python file like ./hello.py
In terminal type the following command
cp filename.py ~/bin/new_name_you want_to_run_with
For example I want to run this file by calling welcome, I will do
cp hello.py ~/bin/welcome
Does the program update when you add it to bin? (eg. I add a new "print" line after I add the program to bin. Will it work?)