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

Edward Elliott nobody at 127.0.0.1
Thu May 4 14:23:18 EDT 2006


Michele Simionato wrote:
>> >>> A = []  # let's declare a "constant" here
>> >>> b = A   # and let's assign the constant here
>> >>> b.append('1') # OOPS!
> 
> But it makes no sense to use a mutable object for a constant!
> The user should use a tuple, 

Sure.  Now show me the builtin immutable equivalent of a dict.

> or a custom list-like type where 
> all methods with side effects are removed, so it effectively acts
> as a tuple.

Ugh, not worth the trouble imo.





More information about the Python-list mailing list