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

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu May 4 18:08:10 EDT 2006


tsaar2003 at yahoo.com a écrit :
> Bruno Desthuilliers wrote:
> 
>>tsaar2003 at yahoo.com a écrit :
>>
>>>Hi Pythonians,
>>>
>>>To begin with I'd like to apologize that I am not very experienced
>>>Python programmer so please forgive me if the following text does not
>>>make any sense.
>>>
>>>I have been missing constants in Python language.
>>
>>Why so ?
>>
>>I guess you're talking about named (symbolic) constants ? If so, just
>>follow the convention : a name in ALL_UPPERCASE is a constant (or at
>>least will be treated as such by anyone not wanting to mess with your
>>package's implementation). No need to add extra syntax here IMHO.
> 
> 
> Hi Bruno,
> 
> For example:
> 
> 
>>>>A = []  # let's declare a "constant" here

Uh ? That's the strangest idea I've ever seen - I mean, using an empty 
list as a constant... If you need your constant to be a sequence (while 
I can't imagine any reason to do so), use a tuple.

(snip)

> As you can see, the "constant" A can be modified this easily. But if
> there were an intuitive mechanism to declare a symbol to be immutable,

Don't worry about the symbol, use an immutable type !-)



More information about the Python-list mailing list