On Saturday 20 October 2007, [EMAIL PROTECTED] wrote: > hi > > what is the difference between the two kinds of brackets? > I tried a few examples but I can't make out any real difference:
Lists are mutable, tuples aren't: Python 2.4.4 (#2, Aug 16 2007, 00:34:54) [GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> l = [1,2,3] >>> t = (1,2,3) >>> type(l) <type 'list'> >>> type(t) <type 'tuple'> >>> l[0] 1 >>> t[0] 1 >>> l[0] = 12 >>> t[0] = 12 Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: object does not support item assignment >>> Also, parentheses can be skipped (as in t = 1,2,3), the comma is the maker for a tuple (exception: empty tuple == (), but one-element-tuple == ("foo",)) -- Regards, Thomas Jollans GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu Hacker key <http://hackerkey.com/>: v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6
signature.asc
Description: This is a digitally signed message part.
-- http://mail.python.org/mailman/listinfo/python-list