lambda

Antoon Pardon apardon at forel.vub.ac.be
Tue Jan 18 07:04:48 EST 2005


Op 2005-01-18, Simon Brunning schreef <simon.brunning at gmail.com>:
> On 18 Jan 2005 07:51:00 GMT, Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>> 3 mutating an item in a sorted list *does* *always* cause problems
>
> No, it doesn't. It might cause the list no longer to be sorted, but
> that might or might no be a problem.

Than in the same vain I can say that mutating a key in a dictionary
doesn't always cause problems either. Sure it may probably make a
key unaccessible directly, but that might or might not be a problem.

>> More specific the Decimal class is mutable and usable as dict key.
>
> Decimal objects are immutable, so far as I know.
>
>>>> from decimal import Decimal
>>>> spam = Decimal('1.2')
>>>> eggs = spam
>>>> eggs is spam
> True
>>>> eggs += 1
>>>> eggs is spam
> False
>

>>> from decimal import Decimal
>>> spam = Decimal('1.2')
>>> egg = spam
>>> spam._int = (1, 3)
>>> spam
Decimal("1.3")
>>> spam is egg
True

-- 
Antoon Pardon



More information about the Python-list mailing list