var or inout parm?

Marc 'BlackJack' Rintsch bj_666 at
Fri Dec 12 17:21:29 CET 2008

On Fri, 12 Dec 2008 07:56:58 -0800, sturlamolden wrote:

> On Dec 12, 4:55 pm, sturlamolden <sturlamol... at> wrote:
>> def __setitem__(self, index, value):
>>    if _buf[index] is not value: # given that _buf is the tuple's
>> internal buffer
>>       raise TypeError, 'tuple' object does not support item
>> assignment
> blæh, that should be self._buf[index]

But then the error message is not true anymore because tuples *would* 
support item assignment when the old and new value are the same.  Which 
leads to strange things like code that may or may not raise that 
exception, depending on implementation details:

t = (1, 2)
t[0] = 1   # Maybe okay -- maybe not.
t[1] += 0  # Same here.

I'd find that quite odd.

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list