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

Diez B. Roggisch deets at nospam.web.de
Wed May 3 13:48:13 EDT 2006


Edward Elliott wrote:

> Michele Simionato wrote:
>> 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.
> 
> Which doesn't apply here, one of the OP's examples further up this thread
> doesn't modify any ALL CAPS vars directly:
> 
>>>> A = []  # let's declare a "constant" here
>>>> b = A   # and let's assign the constant here
>>>> b.append('1') # OOPS!

That leads to the question of forbidding mutable methods. Which will require
const-declarations on methods that in turn are only allowed to invoke
const-methods themselves.

Bottom line is: if one wants static typing and full control over
construction of new pobjects when merely assigning, use C++ :)

diez



More information about the Python-list mailing list