curly-brace-aphobic?
D-Man
dsh8290 at rit.edu
Mon Jan 29 12:30:30 EST 2001
On Mon, Jan 29, 2001 at 08:35:42AM -0600, Grant Griffin wrote:
| C.Laurence Gonsalves wrote:
| >
| ...
| > I'm not sure why you need to be reminded whether something is a sequence
| > or a dictionary.
|
| 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. It seems to me that a list is a special case of a dictionary.
How about classes that implement __getitem__? They perform the same
operation, just according to their own rules. If the class is written
to follow the same rules a dictionary or a list follows, but do some
extra magic on the side, it could be used in place of the
dictionary/list without any modification to the client code.
I think that the same syntax is used because they are the same
operation, just slightly different restrictions/rules.
Just my own $0.02.
-D
More information about the Python-list
mailing list