So I wanted to check out some implementations of standard libraries. I started with the os library with the code being here on github.
I took one method for example os.listdir()
and I have absolutely no idea how it is implemented even after looking at the code ( pardon this noob ). I have following questions:
os.__all__
do not list this method but I think it is definitely a method as print(type(os.listdir))
listed <class 'builtin_function_or_method'>
and I searched on google to find all the builtin functions which I found on this doc page and this is not one of them.listdir
defined in the module. In the code, from my limited understanding, the function is taken from globals()
and put into a support_fd
set. How this method is being called I do not understand.I think the main problem I have is how that module is designed and I was not able to find any resources online to explain in simpler terms hence I am asking here for pointers.
EDIT: For those who are asking, I tried the following code in onlinegdb
import os
if "listdir" in os.__all__:
print("Yes")
print(os.listdir())
The result is only main.py
, it should also print Yes
, maybe the platform onlinegdb
is the problem but it clearly shows the output of listdir
as main.py
.
After having discussion in the comments I see now that this is more of a online python version problem and not an issue with python or the module itself.