script
A program, usually short, that is run directly to do a job, as opposed to a module written to be imported.
In more detail
A Python script is simply a .py file run with python3 name.py. To run it by name, give it a shebang and execute permission on macOS and Linux, or install it as an entry point.
Related terms
- .py file — A plain text file whose name ends in .py, holding Python source code that the interpreter can run or import.
- shebang — The first line of a script, starting with #!, that names the program the operating system should use to run it.
- entry point — A declared command name that, when your package is installed, becomes a real command which calls a chosen function.
- main guard — The line if __name__ == "__main__": which runs the block beneath it only when the file is run as a program, not when it is imported.
Taught in
- What Python Is, And Where It Came From — Hands-on Python: Complete Video Course & Book
- Installing Python On Windows — Hands-on Python: Complete Video Course & Book
- Installing Python On A Mac — Hands-on Python: Complete Video Course & Book
- CGI: Dynamic Web Pages — Hands-on Python: Complete Video Course & Book
- HTML Forms And Dynamic Programs — Hands-on Python: Complete Video Course & Book
- Virtual Environments — Hands-on Python: Complete Video Course & Book