Python: Where Is The Code For Os.mkdir?
I've been looking through the code of the os module (just to be clear, I'm looking at the file /usr/lib/python2.7/os.py), and I've been trying to find the code for the mkdir functi
Solution 1:
On POSIX platforms (and on Windows and OS/2) the os
module imports from a C module, defined in posixmodule.c
.
This module defines a posix_mkdir()
function that wraps the mkdir()
C call on POSIX platforms, CreateDirectoryW
on Windows.
The module registers this function, together with others, in the module PyMethodDef posix_methods
structure. When the module is imported, Python calls the PyMODINIT_FUNC()
function, which uses that structure to create an approriate module object with the posix_methods
structure and adds a series of constants (such as the open()
flag constants) to the module.
See the Extending Python with C or C++ tutorial on how C extensions work.
Post a Comment for "Python: Where Is The Code For Os.mkdir?"