3
I’m studying the módulo os
of the standard library of Python
and I realize that in many cases a function is allowed to receive as a parameter a descritor de arquivo ou diretório
some examples are:
os.fchdir(fd)
Change the Current Working directory to the directory represented by thefile descriptor fd
. The Descriptor mustrefer to an opened directory
, not an open file. As of Python 3.3, this is equivalent to `os.chdir(fd).
os.supports
_fd ASet object indicating which functions in the os module permit specifying their path parameter as an open file descriptor
. Different Platforms provide Different Functionality, and an option that Might work on one Might be Unsupported on Another. For Consistency’s sakes, functions that support fd Always allow specifying the Parameter, but will raise an Exception if the Functionality is not Actually available.To check whether a particular Function Permits specifying an open file Descriptor for its path Parameter, use the in Operator on supports_fd. As an example, this Expression determines whether os.chdir() accepts open file Descriptors when called on your local Platform:
os.chdir in os.supports_fd
My doubts are:
- What is a
descritor de arquivo
? - What is a
descritor de diretório aberto
?
Thank you again for that enlightening reply. I thank you.
– ThiagoO