Defining/declaring constants in Python

Michael Hudson mwh at python.net
Tue Jul 29 07:56:54 EDT 2003


Christopher Koppler <klapotec at chello.at> writes:

> If you really, really, REALLY want a varia^Wconstant that cannot be
> changed, no matter how hard you try, in Python, have a look at this:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207

Of course, it's still possbile to change the values of these
'constants', you just have to muck about quite a bit to manage it.

Making something really, truly, constant in Python is probably
impossible (and certainly hard enough to be a silly thing to do in
real code).

Cheers,
mwh

-- 
  MAN:  How can I tell that the past isn't a fiction designed to
        account for the discrepancy between my immediate physical
        sensations and my state of mind?
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 12




More information about the Python-list mailing list