Skip to Main Content
Programming Python, 3rd Edition
book

Programming Python, 3rd Edition

by Mark Lutz
August 2006
Intermediate to advanced content levelIntermediate to advanced
1600 pages
51h 46m
English
O'Reilly Media, Inc.
Content preview from Programming Python, 3rd Edition

Automated Program Launchers

Suppose, for just a moment, that you wish to ship Python programs to an audience that may be in the very early stages of evolving from computer user to computer programmer. Maybe you are shipping a Python application to nontechnical users, or perhaps you’re interested in shipping a set of Python demo programs with a book. Whatever the reason, some of the people who will use your software can’t be expected to do anything more than click a mouse. They certainly won’t be able to edit their system configuration files to set things such as PATH and PYTHONPATH per your programs’ assumptions. Your software will have to configure itself.

Luckily, Python scripts can do that too. In the next three sections, we’re going to study three modules that aim to automatically launch programs with minimal assumptions about the environment on the host machine:

Launcher.py

A library of tools for automatically configuring the shell environment in preparation for launching a Python script. It can be used to set required shell variables—both the PATH system program search path (used to find the “python” executable) and the PYTHONPATH module search path (used to resolve imports within scripts). Because such variable settings made in a parent program are inherited by spawned child programs, this interface lets scripts preconfigure search paths for other scripts.

LaunchBrowser.py

Aims to portably locate and start an Internet browser program on the host machine in order to view a local ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python, 3rd Edition

Learning Python, 3rd Edition

Mark Lutz

Publisher Resources

ISBN: 0596009259Supplemental ContentErrata Page