[Tutor] Tuple - Immutable ?

col speed ajarncolin at gmail.com
Thu Mar 8 12:33:17 CET 2012


On 8 March 2012 18:27, Walter Prins <wprins at gmail.com> wrote:
> Just to add, notice that even for lists,
>
> l = l + [7,8,9]
>
> produces a new list, while
>
> l += [7,8,9]
>
> does not.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

I was just thinking about the immutability of things and tried this
(which -at least I- find interesting:

>>> id(1)
154579120
>>> a = 1
>>> id(a)
154579120
>>> a += 2
>>> id(a)
154579096
>>> id(3)
154579096
>>> a is 3
True
>>>
Although there is probably no other logical way of doing it - I learnt
something new again!


More information about the Tutor mailing list