curly-brace-aphobic?

Grant Griffin not.this at seebelow.org
Tue Jan 30 13:30:51 EST 2001


In article <mailman.980870616.378.python-list at python.org>, D-Man says...
>
...
>I still maintain my postiion that a list is really a special case of a
>dictionary, on a theoretical level.

I guess I'm not much of a theoretician, but I disagree.  A list does something
_less_ than a dictionary (in that its indexing value is limited in terms of both
type and value), but it also does something _more_ than a dictionary in that it
has a sequence.  FWIW, here's a little hierarchy:

indexers
   sequences
      mutable
         lists
      immutable
         tuples
         strings
   dictionaries

Of course, one could create other hierarchies:

mutable
   lists
   dictionaries
immutable
   strings
   tuples

or even:

containers
   arrays
      mutable
         lists
      immutable
          tuples
          strings
   dictionaries

This last one is how I tend to think of it.  I _think of_ tuples as a special
case of lists: "tuples are read-only lists".  Likewise, one can _think of_
strings as special cases of lists: "strings are imutable lists that can contain
only characters".

But if we try to generalize a relationship between dictionaries and lists, we
find that we can make neither a special case of the other--at least without
stretching it pretty far.

Given the "indexers" hierarchy at top, the Python rule seems to be "All indexers
are indexed using square braces".  Those who find Python's bracing "consistent"
evidently are evaluating "consistency" in terms of this rule.

However, the rule that I seem to want to apply is "All indexers are indexed
using the style of brace used to bind them."  (If a certain style of brace is
good enough to bind a variable, why isn't it good enough to _access_ a
variable?)  That being said, it may not be possible (and it certainly isn't
desirable) to index strings and tuples using this rule.

But I see no reason why curly braces could not be used for this purpose.

explict-is-better-than-implicit-ly y'rs,

=g2
p.s.  Just for the record, I'm not recommending any change to Python--because
the needs of backwards compatibility would undoubtedly lead to the dreaded "more
than one way to do it" <wink>. I was just asking a question.  Thanks to all for
the many kind answers.

_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation            http://www.iowegian.com




More information about the Python-list mailing list