There is more than one way to do it - and for no apparent reason.

Alex Martelli aleax at
Mon Feb 18 13:24:53 CET 2002

Max M wrote:
> Basically you can say that JScript uses the dictionary notation for
> getting attributes. As fas I can see this is smarter than the way we do

Maybe you can't see very far....?-)

adict = dict()
somerandomwordfromsomewhere = 'get'
adict[somerandomwordfromsomewhere] = 23

Now what should adict.get be?  The number 23, or a bound method that you
can save somewhere and later call with an argument or two?

If items and attributes were confused, you basically couldn't use
bound methods any more -- you could never be sure if by some
mischance somebody has set an item called get, or keys, or items,
or setdefault, or ... whatever other name you might like to use.

> I know it's just syntactic sugar, but it would be so sweet.
> Is there any reason why not to do it?

Hmmm, the risk to one's teeth, maybe?


More information about the Python-list mailing list