Const in python?

Bernt Ribbum bernt at tordivel.no
Mon Mar 24 20:18:46 CET 2003


Alex Martelli has a pretty neat solution to this in the Python Cookbook.
Look at

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207

--

- Bernt
---------------------------------------------------------------------------
TORDIVEL AS  http://www.tordivel.no
Storgata 20  0184 OSLO  NORWAY
Tel +47 2315 8700  Fax +47 2315 8701
Bernt Ribbum  bernt at tordivel.no  bernt.ribbum at ieee.org
Direct: +47 2315 8714  Mobile: +47 906 106 85
---------------------------------------------------------------------------

"Anand" <anand at calbay.com> wrote in message
news:c6303995.0303241023.4d106ab6 at posting.google.com...
> Wouldn't it be a nice idea to have constants in Python? I think when
> programmers intend some of the variables to be const, the behavior
> shouldn't be allowed to be altered. It would be nice to declare
> 'maxint' in sys to be a const rather than allowing programmers to
> change the value and cause the program to fail as a result of this
> change.
>
> Anand.
> anand at calbay.com (Anand) wrote in message
news:<c6303995.0303232258.7e77682 at posting.google.com>...
> > Python 2.3a2 (#39, Feb 19 2003, 17:58:58) [MSC v.1200 32 bit (Intel)] on
win32
> > Type "copyright", "credits" or "license" for more information.
> > IDLE 0.8 -- press F1 for help
> > >>> True
> >  True
> > >>> False
> >  False
> > >>> True = False
> > >>> True
> >  False
> > >>> False
> >  False
> > >>>
> >
> > has anyone tried this before?
> >
> > Anand






More information about the Python-list mailing list