Say Suppose, the name of my python script file is hello. How the script can be executed ? Sometimes, I see that most of the python scripts are executed by (python hello.py) and sometimes (./hello.py). Which one of these executing is true? If both are same, why it is mentioned as different commands?
1 Answer
The syntax ./hello.py is typically used on Unix-like systems (including Linux and OSX); it requires two things:
- that
hello.pyhas proper rights (execute bit set) - that the first line of
hello.pyis#!/usr/bin/python(or similar, depending on location of your Python interpreter)
The other form - python hello.py - does not have such requirements.
perl file.py, because perl is a different programming language