Reputation: 51
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?
Upvotes: 1
Views: 218
Reputation: 12927
The syntax ./hello.py
is typically used on Unix-like systems (including Linux and OSX); it requires two things:
hello.py
has proper rights (execute bit set)hello.py
is #!/usr/bin/python
(or similar, depending on location of your Python interpreter)The other form - python hello.py
- does not have such requirements.
Upvotes: 5