[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.

-eric


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



More information about the Python-ideas mailing list