3 ms·
"Third party" means a third party provided it: not yourself, and not the Python distribution, but someone else. "os" is a second-party library. You didn't wri
by gmfawcett 6y ago
"Third party" means a third party provided it: not yourself, and not the Python distribution, but someone else.
"os" is a second-party library. You didn't write it; it was included in the Python distribution for you.
What you're asking, I think is why the "os" functions are not, in Python terminology, "builtins." The builtins are functions that are available without any kind of import: like len(), max(), sorted(), etc.
https://docs.python.org/3/library/functions.html https://docs.python.org/3/library/functions.html
Why do you have to "import os"? Python was designed that way, that's all. So were the majority of other languages that come with standard libraries. (JavaScript is one exception that comes to mind, but there aren't many such exceptions.)
The discussion above relates to "virtual environments", which are ways to manage third-party dependencies. My claim is that virtualenvs, while handy for general-purpose development, are basically pointless for replacing shell scripts. You don't need them -- the core language and its standard library are sufficient for most shell scripting purposes. I'm basing this opinion on my ~20 years of using Python for this kind of work.