[Python-ideas] Dict-like object with property access

Eric Snow ericsnowcurrently at gmail.com
Tue Jan 31 19:06:43 CET 2012

On Tue, Jan 31, 2012 at 12:10 AM, Georg Brandl <g.brandl at gmx.net> wrote:
> If anything, the d.[name] (short for getattr(d, name)) proposal should be
> reconsidered.  But IIRC it was concluded when discussed last time that the
> syntax is too hard to quickly distinguish from item access, and a better
> one couldn't be found.

The last discussion I recall for that syntax was less than a year
ago[1] and got lost amid other proposals.  The idea did come up (and
floundered) in 2007, though.  It would be worth having another look.
As Raymond put it[2]:

    IIRC, the idea for a __getattr__ syntax was favorably received at first,
    but it then drowned in a sea of syntax bikeshedding which precluded any
    serious discussion of use cases and benefits.

    Also remember that not all dead proposals have to stay dead.  When
    generator expressions were first proposed, the PEP was rejected.
    The same was true for generator exceptions and for pushing data into
    running generators, yey these were ultimately accepted in the form of
    throw() and send().

+1 for reconsidering the d.[name] / d.(name) / d!name syntax.


[1]  blow-by-blow compilation from March 2011:
 * Raymond brought it up --
 * ...and remained relatively neutral --
 * Greg Ewing approved --
 * Guido was thinking about it --
 * Larry Hastings on the 2007 thread --
 * Raymond in response --
[2]  http://mail.python.org/pipermail/python-ideas/2011-March/009286.html

More information about the Python-ideas mailing list