list vs tuple
sholden at holdenweb.com
Wed Mar 28 23:50:58 CEST 2001
"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:99teuu02p5f at news1.newsguy.com...
> "Rikard Bosnjakovic" <bos at hack.org> wrote in message
> news:3AC1F93A.BAC9E34B at hack.org...
> > deadmeat wrote:
> > > so is that the only difference?
> > Both are sequences, but tuples are "read-only", that's the only
> > difference (except for the in-place-methods which requires mutability).
> Actually, tuples have NO methods -- including those that would
> require no mutability at all:
> Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> >>> dir()
> ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
> >>> dir(())
> Note the lack of 'count' and 'index', which do not mutate a list
> when applied to it, but are still missing from tuples.
So, tuples are not only immutable, they are also uncooperative.
More information about the Python-list