cpython - Python: where is the method listdir because there is no "def listdir()" in module os.py? -
python: wonder method listdir because not in module os.py. in module there no method:
def listdir ()
the listdir
method implemented in c module, , imported dynamically depending on operating system environment. can see imports near top of os.py
, in blocks :
if 'posix' in _names: name = 'posix' linesep = '\n' posix import *
then file posixmodule.c
in python source has posix implementation of listdir
: https://github.com/python-git/python/blob/master/modules/posixmodule.c#l2068 (and likewise other oses).
Comments
Post a Comment