Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all built in libraries in Python

Tags:

python

I've recently started with Python, and am enjoying the "batteries included" design. I'e already found out I can import time, math, re, urllib, but don't know how to know that something is builtin rather than writing it from scratch.

What's included, and where can I get other good quality libraries from?

like image 743
Rich Bradshaw Avatar asked Nov 30 '08 22:11

Rich Bradshaw


People also ask

How do I get all built-in modules in Python?

The compiled-in module names are in sys. builtin_module_names . For all importable modules, see pkgutil.

How do I get a list of libraries installed in Python?

The Pip, Pipenv, Anaconda Navigator, and Conda Package Managers can all be used to list installed Python packages. You can also use the ActiveState Platform's command line interface (CLI), the State Tool to list all installed packages using a simple “state packages” command.

What are the inbuilt libraries in Python?

Python standard library. The Python Standard Library contains the exact syntax, semantics, and tokens of Python. It contains built-in modules that provide access to basic system functionality like I/O and some other core modules. Most of the Python Libraries are written in the C programming language.

Where are Python libraries found?

Python looks for modules in “sys. It looks for a file called a_module.py in the directories listed in the variable sys. path .


1 Answers

Firstly, the python libary reference gives a blow by blow of what's actually included. And the global module index contains a neat, alphabetized summary of those same modules. If you have dependencies on a library, you can trivially test for the presence with a construct like:

try:
    import foobar
except:
    print 'No foobar module'

If you do this on startup for modules not necessarily present in the distribution you can bail with a sensible diagnostic.

The Python Package Index plays a role similar to that of CPAN in the perl world and has a list of many third party modules of one sort or another. Browsing and searching this should give you a feel for what's about. There are also utilities such as Yolk which allow you to query the Python Package Index and the installed packages on Python.

Other good online Python resources are:

  • www.python.org

  • The comp.lang.python newsgroup - this is still very active.

  • Various of the items linked off the Python home page.

  • Various home pages and blogs by python luminaries such as The Daily Python URL, effbot.org, The Python Cookbook, Ian Bicking's blog (the guy responsible for SQLObject), and the Many blogs and sites off planet.python.org.

like image 121
ConcernedOfTunbridgeWells Avatar answered Oct 02 '22 16:10

ConcernedOfTunbridgeWells