Chapter 11. Python programs

 

This chapter covers

  • Creating a very basic program
  • Making a program directly executable on Linux/UNIX
  • Writing programs on macOS
  • Selecting execution options in Windows
  • Combining programs and modules
  • Distributing Python applications

Up until now, you’ve been using the Python interpreter mainly in interactive mode. For production use, you’ll want to create Python programs or scripts. Several of the sections in this chapter focus on command-line programs. If you come from a Linux/UNIX background, you may be familiar with scripts that can be started from a command line and given arguments and options that can be used to pass in information and possibly redirect their input and output. If you’re from a Windows or Mac background, these things may be new to you, and you may be more inclined to question their value.

It’s true that command-line scripts are sometimes less convenient to use in a GUI environment, but the Mac has the option of a UNIX command-line shell, and Windows also offers enhanced command-line options. It will be well worth your time to read the bulk of this chapter at some point. You may find occasions when these techniques are useful, or you may run across code you need to understand that uses some of them. In particular, command-line techniques are very useful when you need to process large numbers of files.

11.1. Creating a very basic program

11.2. Making a script directly executable on UNIX

11.3. Scripts on macOS

11.4. Script execution options in Windows

11.5. Programs and modules

11.6. Distributing Python applications

Summary

sitemap