How to find all built in libraries in 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?
Asked by: Ada117 | Posted: 28-01-2022
Answer 1
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:
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.
Answer 2
run
pydoc -p 8080
and point your browser to http://localhost:8080/
You'll see everything that's installed and can spend lots of time discovering new things. :)
Answered by: Elise593 | Posted: 01-03-2022Answer 3
The Python Global Module Index (http://docs.python.org/modindex.html) lists out every module included in Python 2.6.
Sourceforge has all sorts of good Python modules - one that came in handy for me recently was PyExcelerator, a module for writing straight to MS Excel workbooks. The Python Package Index, (http://pypi.python.org/) is also a good source of Python modules.
Answered by: Kelvin284 | Posted: 01-03-2022Answer 4
Doug Hellman's blog covers lots of built-in libraries in depth. If you want to learn more about the standard library you should definitely read through his articles.
Answered by: Nicole535 | Posted: 01-03-2022Answer 5
This is not directly related to your question, but when you're in the python console, you can call help() on any function and it will print its documentation.
also, you can call dir() on any module or object and it will list all of its attributes, including functions.
This useful for inspecting contents of a module after you've imported it.
>>> import math
>>> dir(math)
['__doc__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'degrees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log', 'log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']
>>> help( math.log )
Help on built-in function log in module math:
log(...)
log(x[, base]) -> the logarithm of x to the given base.
If the base not specified, returns the natural logarithm (base e) of x.
Answered by: Haris186 | Posted: 01-03-2022
Similar questions
OCSP libraries for python / java / c?
Going back to my previous question on OCSP, does anybody know of "reliable" OCSP libraries for Python, Java and C?
I need "client" OCSP functionality, as I'll be checking the status of Certs against an OCSP responder, so responder functionality is not that important.
Thanks
how do i use python libraries in C++?
I want to use the nltk libraries in c++.
Is there a glue language/mechanism I can use to do this?
Reason:
I havent done any serious programming in c++ for a while and want to revise NLP concepts at the same time.
Thanks
How can I use Perl libraries from Python?
I have written a bunch of Perl libraries (actually Perl classes) and I want to use some of them in my Python application. Is there a natural way to do this without using SWIG or writing Perl API for Python. I am asking for a similar way of PHP's Perl interface. If there is no such kind of work for Perl in Python. What is the easiest way to use Perl cl...
macos - Mac Based Python GUI Libraries
I am currently building a GUI based Python application on my mac and was wondering could anyone suggest a good GUI library to use?
I was looking at python's gui programming faq and there was a lot of options making it hard to choose.
I am developing on snow leopard and cross-platform is not essential (if it makes a differenc...
Tree libraries in python
Closed. This question does not meet Stack Overflow guid...
Are there any libraries to allow Python or Ruby to get info from SVN?
I'm looking for plugins that will allow my codebase to interact with, browse, and poll an SVN server for information about a repository.
Trac can do this, but I was hoping there was an easy-to-use library available to accomplish the task, rather than trolling through the Trac codebase. Googling for this returns mostly vague results about storing you...
Does python import all the listed libraries?
I'm just wondering, I often have really long python files and imports tend to stack quite quickly.
PEP8 says that the imports should always be written at the beginning of the file.
Do all the imported libraries get imported when calling a function coded in the file? Or do only the necessary libraries get called?
Does it make sense to worry about this? Is there no reason to import libraries wit...
python - ctypes for static libraries?
I'm attempting to write a Python wrapper for poker-eval, a c static library. All the documentation I can find on ctypes indicates that it works on shared/dynamic libraries. Is there a ctypes for static libraries?
I know about cython, but should I use that or recompile the poker-eval into a dynamic library so that I can use ctypes?
Thanks,
Mike
Ruby Vs Python - Socket Libraries
I have a concept I'd like to work on that requires the use of low-level sockets (i.e.: no frameworks or wrappers, just the standard send/recv pattern included in most standard libraries.
I'm familiar with both Ruby and Python, and from my (limited) experience they seem to have similar socket libraries. What I'd like to know is if either language has any advantage, whether it be with performance, stability, ease-of...
python - Good sound libraries?
web crawler - What are the best prebuilt libraries for doing Web Crawling in Python
This question already has answers here:
OCSP libraries for python / java / c?
Going back to my previous question on OCSP, does anybody know of "reliable" OCSP libraries for Python, Java and C?
I need "client" OCSP functionality, as I'll be checking the status of Certs against an OCSP responder, so responder functionality is not that important.
Thanks
how do i use python libraries in C++?
I want to use the nltk libraries in c++.
Is there a glue language/mechanism I can use to do this?
Reason:
I havent done any serious programming in c++ for a while and want to revise NLP concepts at the same time.
Thanks
How can I use Perl libraries from Python?
I have written a bunch of Perl libraries (actually Perl classes) and I want to use some of them in my Python application. Is there a natural way to do this without using SWIG or writing Perl API for Python. I am asking for a similar way of PHP's Perl interface. If there is no such kind of work for Perl in Python. What is the easiest way to use Perl cl...
Python vs. C# Twitter API libraries
Closed. This question does not meet Stack Overflow guid...
d - Calling gdc/dmd shared libraries from Python using ctypes
I've been playing around with the rather excellent ctypes library in Python recently. What i was wondering is, is it possible to create shared D libraries and call them in the same way. I'm assuming i would compile the .so files using the -fPIC with dmd or gdc and call them the same way using the ctypes library.
Has anyone tried this ? ...
plot - Python plotting libraries
Closed. This question does not meet Stack Overflow guid...
HTML Agility Pack or HTML Screen Scraping libraries for Java, Ruby, Python?
I found the HTML Agility Pack useful and easy to use for screen scraping web sites. What's the equivalent library for HTML screen scraping in Java, Ruby, Python?
c - Building a Python shared object binding with cmake, which depends upon external libraries
We have a c file called dbookpy.c, which will provide a Python binding some C functions.
Next we decided to build a proper .so with cmake, but it seems we are doing something wrong with regards to linking the external library 'libdbook' in the binding:
The CMakeLists.txt is as follows:
PROJECT(dbookpy)
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE...
shared libraries - Can two versions of the same library coexist in the same Python install?
The C libraries have a nice form of late binding, where the exact version of the library that was used during linking is recorded, and thus an executable can find the correct file, even when several versions of the same library are installed.
Can the same be done in Python?
To be more specific, I work on a Python project that uses some 3rd-party libraries, such as paramiko. Paramiko is now version 1.7.4, bu...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python