Reputation: 31
Where is the source code for os.remove() in python? In the following file "https://github.com/python/cpython/blob/master/Lib/os.py", some functions of "os" are given but I couldn't find the definition for "remove".
Basically I want to check how remove() is implemented in python.
Upvotes: 2
Views: 1018
Reputation: 34744
It's here for POSIX:
At the top of os.py
you see it imports a module named posix
if it's running on POSIX:
https://github.com/python/cpython/blob/master/Lib/os.py#L64
if 'posix' in _names:
# ...
import posix
__all__.extend(_get_exports_list(posix))
It is a built-in module defined at the bottom of posixmodule.c
:
#define MODNAME "posix"
// ...
static struct PyModuleDef posixmodule = {
PyModuleDef_HEAD_INIT,
MODNAME,
// ...
};
// ...
PyMODINIT_FUNC
INITFUNC(void)
{
// ...
m = PyModule_Create(&posixmodule);
// ...
Upvotes: 2