A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/087035.html below:

Why tuples ???

Why tuples ???Fredrik Lundh fredrik at pythonware.com
Mon Apr 23 12:18:39 EDT 2001
Thomas Weidner wrote:
> I started lerning Python and discovered tuples, but why do they exist ?
> What's the difference from a list ?

did you remember to check the FAQ?

    http://www.python.org/doc/FAQ.html#6.15
    Q. Why are there separate tuple and list data types?

also consider this code fragment:

>>> T = (1, 2, 3)
>>> L = (1, 2, 3)

>>> D = {}
>>> D[T] = "spam"
>>> D[L] = "spam"
Traceback (innermost last):
  File "<stdin>", line 1, in ?
TypeError: unhashable type

>>> T.append(4)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
AttributeError: 'tuple' object has no attribute 'append'
>>> L.append(4)
>>> L
[1, 2, 3, 4]

Cheers /F



More information about the Python-list 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