1

After reading http://docs.python.org/2/library/allos.html, I am a bit unclear on whether the os module contains functions that perform the same functions as system commands or if they are calling system commands. I did not see a link to the source code.

I have just started working with Python and the os module. Can someone clue me in to the nature of these functions and where I might find the source code?

1 Answers1

2

The os module uses per-OS-specific packages, most of which use standard C calls, the same calls the command-line tools would have to use.

You want to study the os.py module source first, then platform-specific modules. posixmodule.c handles OS calls for UNIX, OS/2 and Windows.

For example, the os.listdir() function uses opendir, readdir and closedir calls on POSIX systems.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343