1

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?

3
  • 2
    they both are same, depending on your operating system and your system configuration either one or both can be used. Commented Jul 5, 2017 at 11:46
  • Perl file.py is used by which operating system and ./python.py is used by which OS? Commented Jul 5, 2017 at 11:53
  • 1
    you can't run python by perl file.py, because perl is a different programming language Commented Jul 5, 2017 at 17:31

1 Answer 1

5

The syntax ./hello.py is typically used on Unix-like systems (including Linux and OSX); it requires two things:

  1. that hello.py has proper rights (execute bit set)
  2. that the first line of 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.