Possible constant assignment operators ":=" and "::=" for Python

Michele Simionato michele.simionato at gmail.com
Wed May 3 06:24:37 EDT 2006


tsaar2003 at yahoo.com wrote:
> As stated in my first post, I am quite newbie in
> Python and miss a simple and intuitive mechanism that would allow to
> declare something as constant and that would protect these "constant"
> objects from accidental modifications.
>
> T.S.

Python solution is to rely on the intelligence of programmers. If they
see
an all caps name and then they try to change it without knowing what
they are doing,
then they are stupid. If you have stupid programmers there is no way
the
language can stop them for making disasters.
For true constants, this is the end of the story. OTOH, sometimes you
want
read-only attributes which should not be accidentally overwritten but
that
are not really constants. In this case, the solution is to use
properties.
Just google the newsgroup for "properties" and you will find many
examples
of usage.
 
 Michele Simionato




More information about the Python-list mailing list