A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-March/117255.html below:

[Python-Dev] odd "tuple does not support assignment" confusion...

[Python-Dev] odd "tuple does not support assignment" confusion... [Python-Dev] odd "tuple does not support assignment" confusion...R. David Murray rdmurray at bitdance.com
Sat Mar 3 00:38:50 CET 2012
On Sat, 03 Mar 2012 03:06:33 +0400, "Alex A. Naanou" <alex.nanou at gmail.com> wrote:
> Hi everyone,
> 
> Just stumbled on a fun little thing:
> 
> We create a simple structure...
> 
>   l = ([],)
> 
> 
> Now modify the list, and...
> 
>   l[0] += [1]
> 
> 
> ...we fail:
> ## Traceback (most recent call last):
> ##   File "F:\work\ImageGrid\cur\ImageGrid\src\test\python-bug.py",
> line 17, in <module>
> ##     l[0] += [1]
> ## TypeError: 'tuple' object does not support item assignment

What is even more fun is that the append actually worked (try printing
l).

This is not a bug, it is a quirk of how extended assignment works.
I think there's an issue report in the tracker somewhere that
discusses it.

--David
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4