Possible constant assignment operators ":=" and "::=" for Python
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Thu May 4 18:11:35 EDT 2006
tsaar2003 at yahoo.com a écrit :
> Yes, I know that "constant" A will also be modified as the b[0] points
> to A. Obviously the [] should be marked as immutable, as A is declared
> to be constant thus immutable. If somebody tries to modify this
> immutable object an error would occur.
>
> When I further thought about this problem with constant objects (and
> values), I run into this scenario: What if I want to use a constant
> object/value as a template (or predefined value/class) for a variable:
>
> constant A = ['1'] # let's declare A as immutable constant value/object
> b = A # let's assign b some default value
> b.append('2') # and let's play with b, but I wouldn't want to change A
def A():
return ['1']
b = A()
b.append('2')
More information about the Python-list
mailing list