Yet Another Case Question

Peter Hansen peter at engcorp.com
Mon Feb 24 12:13:39 EST 2003


Roy Smith wrote:
> 
> Alex Martelli  <aleax at aleax.it> wrote:
> > Don't you think math.pi IS a constant?  Yet it's not in ALLCAPS,
> > isn't it?
> 
> Actually, math.PI isn't a constant.  Python is perfectly happy to let
> me do:
> 
> >>> import math
> >>> math.PI = 3
> >>> print math.PI
> 3
> 
> Whether this is a good thing or a bad thing could be debated.

Without reference to the utility of doing so in this specific case,
I would say that in can be a very Good Thing, if nothing else then
in the case of doing unit testing.  Checking whether "constants"
are actually being used properly by changing them and observing the
effects can be a useful approach in certain cases.

-Peter




More information about the Python-list mailing list