() vs []

Xavier Ho contact at xavierho.com
Thu Oct 15 05:33:44 EDT 2009


On Thu, Oct 15, 2009 at 6:55 PM, Tim Golden <mail at timgolden.me.uk> wrote:

> It was added relatively recently, around Python 2.6 I think,
> at least partly as an oh-ok-then reaction to everyone asking:
> "how come lists have .index and .count and tuples don't?"
> and neverending "tuples-are-immutable-lists-no-they-aren't-yes-they-are"
> debate.
>
> Thanks Tim, that explains most things.

Well, I thought to throw this out for fun:

>>> listSet = set(dir(list))
>>> tupleSet = set(dir(tuple))

>>> listSet - tupleSet
{'sort', 'insert', '__reversed__', 'reverse', 'extend', '__delitem__',
'remove',
 '__setitem__', '__iadd__', 'pop', 'append', '__imul__'}

>>> tupleSet - listSet
{'__getnewargs__'}


That would explain the major differences... =]

Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091015/2df0c454/attachment-0001.html>


More information about the Python-list mailing list