Skip to Content
Python Pocket Reference, 3rd Edition
book

Python Pocket Reference, 3rd Edition

by Mark Lutz
February 2005
Intermediate to advanced
160 pages
4h 45m
English
O'Reilly Media, Inc.
Content preview from Python Pocket Reference, 3rd Edition
The os System Module
|
95
altsep
Alternative separator string or None (e.g., / for Windows).
extsep
The character which separates the base filename from the
extension (e.g.,
.).
pathsep
Character used to separate search path components, as
in
the
PATH
and
PYTHONPATH
shell variable settings (e.g.,
;
for
Windows,
:
for Unix).
defpath
Default search path used by os.exec*p* calls if there is no
PATH setting in the shell.
linesep
String used to terminate lines on current platform (e.g.,
\n
for POSIX,
\r
for Mac OS, and
\r\n
for MS-DOS and
Windows).
Shell Commands
These functions run programs in the underlying operating
system.
system(cmd)
Executes a command string cmd in a subshell process.
Returns the exit status of the spawned process. Unlike
popen, does not connect to cmd’s standard streams via
pipes. Hints: add an
& at the end of cmd to run the com-
mand in the background on Unix (e.g.,
os.
system('python main.py &')
); use a DOS start command
to launch programs easily on Windows (e.g.,
os.
system('start file.html')
).
startfile(filepathname)
Starts a file with its associated application. Acts like dou-
ble-clicking the file in Windows Explorer or giving the
filename as an argument to a DOS
start command (e.g.,
with
os.system('start path')). The file is opened in the
96
|
Python Pocket Reference
application with which its extension is associated; ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python Pocket Reference, 5th Edition

Python Pocket Reference, 5th Edition

Mark Lutz
Python Developer's Handbook

Python Developer's Handbook

André Dos Santos Lessa

Publisher Resources

ISBN: 9780596802042Catalog PageErrata