In many .py
files we may see the shebang line on the top of the script. Its purpose is to define the location of the interpreter. By adding the line #!/usr/bin/python3
on the top of the script, we can run the file.py
on a Unix system and automatically will understand that this is a python script. Alternative, you could run the script as python3 file.py
.
For example assume the file.py
is:
#!/usr/bin/python3 print("Hello shebang line")
And we can run on Unix as:
$ ./file.py
Notice that you could have used #!/usr/bin/env python3