[Python-ideas] Dict-like object with property access
Arnaud Delobelle
arnodel at gmail.com
Mon Jan 30 20:56:41 CET 2012
On 30 January 2012 19:25, Ethan Furman <ethan at stoneleaf.us> wrote:
>> I do. The object has two different interfaces for the same values and
>> that's IMO unpythonic. The Zen says
>>
>> "There should be one-- and preferably only one --obvious way to do it."
>
>
> Indeed.
>
> When you have the attribute name stored in a variable, then the one obvious
> way is [] access.
If it's an attribute, the obvious way is getattr(obj, attrname)
> When you already know the attribute name, the one obvious way is . access.
Yes.
--
Arnaud
More information about the Python-ideas
mailing list