..bits & bytes teleported

Saturday Aug 09, 2008

Over the weekend- I had the urge to see what all commands are available for working with Python- so, I typed 'py' and pressed a TAB:

pycentral                pygettext                python
py_compilefiles          pygettext2.5             python2.5
pydoc                    pysupport-movemodules    pyversions
pydoc2.5                 pysupport-parseversions  

Using pydoc:

pydoc is a documentation generator, well described at http://docs.python.org/lib/module-pydoc.html . Here are my 2 cents, (decorated with screenshots) :-)

  $ pydoc -p 9090
  pydoc server ready at http://localhost:9090

starts a web server to serve documentation for Python modules, and can be accessed remotely using the (hostname, port):


You can stop the server using a ctrl + c

pydoc -g brings up a Tk-basd GUI which you can use to search for module documentation:

pyversions

pyversions with its various switches can be used to print information about installed, supported, default runtimes. For eg.

# print default Python version to be used

amit@ubuntu804-book:~$ pyversions -d 
python2.5

# print installed Python versions

amit@ubuntu804-book:~$ pyversions -i
python2.4 python2.5

# print supported Python versions
amit@ubuntu804-book:~$ pyversions -s
python2.4 python2.5

You can also get only the version numbers by adding a '-v' switch as in:

amit@ubuntu804-book:~$ pyversions -v -d
2.5

pyversions can also be used to parses the information of the PythonVersion fields in the package control file. ( I would appreciate some insight into this)

Some other miscellaneous utitlituies :

Footnotes

  • As you must have noticed, there are same utilities with version information and without version information like- python and python2.5, pydoc and pydoc2.5. Actually, in both cases python and pydoc is actually linked to /usr/bin/python2.5 and /usr/bin/pydoc2.5:

    lrwxrwxrwx 1 root root 9 2008-07-02 23:15 /usr/bin/python -> python2.5
    lrwxrwxrwx 1 root root 8 2008-07-02 23:15 /usr/bin/pydoc -> pydoc2.5
    
  • In Debian flavors, the file /usr/share/python/debian_defaults contains information about the Python versions on the system. For eg.
    amit@ubuntu804-book:~$ cat /usr/share/python/debian_defaults 
    [DEFAULT]
    # the default python version
    default-version = python2.5
    
    # all supported python versions
    supported-versions = python2.4, python2.5
    
    # formerly supported python versions
    old-versions = python2.3
    
    # unsupported versions, including older versions
    unsupported-versions = python2.3
    
    
    Refer: http://www.debian.org/doc/packaging-manuals/python-policy/
Happy times with Python!
Comments:

Post a Comment:
Comments are closed for this entry.