constant in python?

Bjorn Pettersen BPettersen at NAREX.com
Fri Aug 17 22:11:52 CEST 2001


> From: liam [mailto:lcampbell at ubytes.com]
> 
> is there a data type like the const in c/c++? ive been 
> combing through the
> doc and it doesnt seem to have one or am i missing something 
> somewhere?

Do you want something you can const_cast away, like in C++, or do you
want something that's guaranteed to be constant? The former is
accomplished idiomatically in Python by using all uppercase variable
names, and then not assigning to them (sort of like C++ declaring
something const and not const_casting it away). Neither C++ nor Python
has reliable ways of ensuring that something cannot be changed.

-- bjorn




More information about the Python-list mailing list