[Python-ideas] Add a dict with the attribute access capability

Rob Cliffe rob.cliffe at btinternet.com
Wed Nov 29 20:03:41 EST 2017


On 29/11/2017 23:34, Chris Barker wrote:
>
>
> On Wed, Nov 29, 2017 at 12:52 AM, Serhiy Storchaka 
> <storchaka at gmail.com <mailto:storchaka at gmail.com>> wrote:
>
>     This is a dict subclass which allows to access items as attributes.
>
>     d = plistlib.Dict()
>     d['a'] = 1
>     assert d.a == 1
>     d.b = 2
>     assert d['b'] == 2
>
>     What do you think about reviving this type as general purpose type
>     in collections or types
>
>
> Am I I the only one that thinks this is a "Bad Idea"?
>
> For me, it simply confuses even more the question of "is this code or 
> is this data?" -- which is a difficult enough design question in a 
> dynamic language.
>
> And the couple of libraries I"ve worked with that do this I liked at 
> first, but grew to find problematic.
>
>
I have also implemented something like this (as a convenience, to hold a 
row from an SQL table).  But it never occurred to me that there should 
be something like it in the stdlib.
Rob Cliffe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171130/b90866b3/attachment.html>


More information about the Python-ideas mailing list