curly-brace-aphobic?

Remco Gerlich scarblac at pino.selwerd.nl
Mon Jan 29 20:38:37 EST 2001


D-Man <dsh8290 at rit.edu> wrote in comp.lang.python:
> On Mon, Jan 29, 2001 at 08:35:42AM -0600, Grant Griffin wrote:
> | C.Laurence Gonsalves wrote:
> | I guess it's because sequences and dictionaries are conceptually very
> | different.  (You can tell, because we have a special word just to
> 
> I'm not sure how different they are conceptually.  A dictionary is a
> collection (sequence) of data that is indexed by arbitrary keys.  A
> list is a collection (sequence) of data that is indexed by integers
> only.

An essential difference is the fact that lists are ordered, but dicts aren't.

So lists have things like append(), and dicts can set items that don't exist
yet. Sorting a list makes sense, sorting a dict doesn't. Et cetera.

But indexing should be the same for lists, dicts, tuples, shelves, arbitrary
instances - it's simply indexing. It does the same thing.

It's almost odd that list/dict indexing is different from indexing a module
or instance...

-- 
Remco Gerlich



More information about the Python-list mailing list