dictionary and __getattr__
Erik Max Francis
max at alcyone.com
Thu Sep 6 11:35:24 EDT 2001
Harald Kirsch wrote:
> Wouldn't it be nice if this would work:
>
> d = {'x': 1}
> print d.x
>
> i.e. every entry in a dictionary is also an attribute of the
> dictionary itself.
Why would it?
Furthermore, what do you do in the not so obvious cases? What happens
if your key is a number? Or contains spaces? Or worse yet, is a tuple?
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ In principle I am against principles.
\__/ Tristan Tzara
Kepler's laws / http://www.alcyone.com/max/physics/kepler/
A proof of Kepler's laws.
More information about the Python-list
mailing list