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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -