curly-brace-aphobic?
Grant Griffin
not.this at seebelow.org
Sun Jan 28 23:04:38 EST 2001
Hi Gang,
I'm sure this has been asked a thousand times, but I haven't seen it
asked lately (or ever <wink>).
Why does Python use square braces ([]) instead of curly braces ({}) when
accessing dictionaries?
This strange inconsistency in Python seems strangely inconsistent with
its otherwise very consistent application of consistency: since we use
curly braces to _create_ dictionaries, why not use them to _access_
dictionaries? (Or better yet, if the underlying design principle is to
access things using a different syntax than what we used to create them,
why not use curly braces to access lists? <wink>)
Anyway, although curly braces are perhaps slightly harder to type than
square braces, this is one example (maybe the only one) where I find
Perl code more readable: I appreciate the mnemonic effect curly braces
have in reminding me that the thing being accessed is a dictionary*.
or-is-python-just-"curly-brace-aphobic?-{wink}-ly y'rs,
=g2
* perl_terminology = { 'dictionary': 'hash' }
-------------
Addendum: Now that I've written all that, I just had a flash. Is it so
that dictionary code can be sortta polymorphic wrt list code?
doesn't-sound-like-a-very-good-reason-to-me...-ly y'rs,
=g3
--
_____________________________________________________________________
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