Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Finding Quality Python Packages

Avatar image for dakshnavenki

dakshnavenki on Dec. 5, 2024

Hello Dan, I have a question on packages. When you say third party packages, I understand those refers to packages we install using pip commands from PyPI. while we have lot of built in packages that comes with python installation. How do we check for available builtin packages like “sys”, “os”. How do identify whether the given package is built in package or third party package?.

Thanks, Venkat

Avatar image for Bartosz Zaczyński

Bartosz Zaczyński RP Team on Dec. 5, 2024

@dakshnavenki There are a few methods to determine Python’s standard library modules:

  1. Check the Python library reference
  2. Check with PyMOTW, although it’s not exhaustive
  3. List the modules programmatically

Here’s the third option:

>>> import pathlib
... import sysconfig
... 
... stdlib = pathlib.Path(sysconfig.get_path("stdlib"))
... modules = [
...     path.stem
...     for path in sorted(stdlib.iterdir())
...     if (path.is_dir() or path.suffix == ".py")
...     and not path.name.startswith("_")
... ]
... 
>>> modules
['abc', 'antigravity', 'argparse', 'ast', ..., 'zoneinfo']

>>> len(modules)
166
Avatar image for dakshnavenki

dakshnavenki on Dec. 6, 2024

Thank you, Bartosz, this helps!

Become a Member to join the conversation.