ARAVINDA VISHWANATHAPURA

Notes for Python beginners

Jul 21, 2010
1 minute read.
python

Using Python documentation similar to unix man pages

pydoc sys

or

python -m pydoc sys

For html documentation

pydoc -p 9000

Now server will start running in port 9000. we can access the documentation in http://localhost:9000

To get help while working inside interpreter, type help()

>>help()

Help prompt will come, now we can type module name to get details about that module.

sys

To list functions/attributes inside a module

import sys
dir(sys)

To get it in readable format

import sys
for i in dir(sys):
    print i

To list builtin functions,

import __builtin__
for i in dir(__builtin__):
    print i

To see which are all the modules loaded in our program

import sys
for i in sys.modules:
    print i, ": ", sys.modules[i]

About Aravinda Vishwanathapura

Co-Founder & CTO at Kadalu Technologies, Creator of Sanka, Creator of Chitra, GlusterFS core team member, Maintainer of Kadalu Storage
Contact: Linkedin | Twitter | Facebook | Github | mail@aravindavk.in