A few beginning questions

Peter Hansen peter at engcorp.com
Mon Jul 14 08:04:29 EDT 2003


richardc wrote:
> 
> Ive just started playing with Python and have a couple of questions.
> 
> Im looking for an agument parsing library (from the command line), Ive come
> across optik and argtools.  What other ones are there are any of them any
> good, is there a 'standard' lib for doing this.

getopt is a long-standing standard module for this, and I find it very
simple and functional for small utilities, while Optik has been assimilated
in the latest release as standard module optparse, as you can see from this page:
http://www.python.org/dev/doc/devel/whatsnew/node18.html#SECTION0001820000000000000000

> Also how should I '#define' magic numbers in Python.  I spent ages looking
> around for a 'define' statement or anything that will allow me to create a
> constant value 'object'.  Am I missing something very obvious ?

Python has no "constants" per se, but you shouldn't need them either.  Just
define variables, following the convention of using ALLCAPS to name them:

  MY_CONSTANT = 5

-Peter




More information about the Python-list mailing list