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

2017-12-01 Thread Ivan Pozdeev via Python-ideas
On 01.12.2017 1:19, Greg Ewing wrote: Ivan Pozdeev via Python-ideas wrote: I needed to hold an external function reference in an object instance (if I assigned it to an attribute, it was converted into an instance method). No, that only happens to functions stored in *class* attributes,

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

2017-11-30 Thread Nick Coghlan
On 30 November 2017 at 05:11, Barry Warsaw wrote: > Serhiy Storchaka wrote: >> In 3.7 I have removed an old-deprecated plistlib.Dict. [1] Actually it >> already was deprecated when the plistlib module was added to the regular >> stdlib in Python 2.6. >> >> Raymond noticed that

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

2017-11-30 Thread Greg Ewing
Ivan Pozdeev via Python-ideas wrote: I needed to hold an external function reference in an object instance (if I assigned it to an attribute, it was converted into an instance method). No, that only happens to functions stored in *class* attributes, not instance attributes. >>> class A: ...

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

2017-11-30 Thread Ivan Pozdeev via Python-ideas
I use argparse.Namespace whenever I need this. In reply to Chris Barker's concern of "is this code or is this data", the last time I used it is when I needed to hold an external function reference in an object instance (if I assigned it to an attribute, it was converted into an instance

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

2017-11-29 Thread Steven D'Aprano
On Wed, Nov 29, 2017 at 10:52:51AM +0200, Serhiy Storchaka wrote: > In 3.7 I have removed an old-deprecated plistlib.Dict. [1] Actually it > already was deprecated when the plistlib module was added to the regular > stdlib in Python 2.6. > > This is a dict subclass which allows to access items

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

2017-11-29 Thread Rob Cliffe
On 29/11/2017 23:34, Chris Barker wrote: On Wed, Nov 29, 2017 at 12:52 AM, Serhiy Storchaka > 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 =

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

2017-11-29 Thread Chris Barker
On Wed, Nov 29, 2017 at 12:52 AM, Serhiy Storchaka 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

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

2017-11-29 Thread Ivan Levkivskyi
On 29 November 2017 at 20:11, Barry Warsaw wrote: > Serhiy Storchaka wrote: > > In 3.7 I have removed an old-deprecated plistlib.Dict. [1] Actually it > > already was deprecated when the plistlib module was added to the regular > > stdlib in Python 2.6. > > > > Raymond noticed

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

2017-11-29 Thread Nick Timkovich
On Wed, Nov 29, 2017 at 7:21 AM, Daniel Moisset wrote: > As reference of prior art, there is https://pypi.python.org/pypi/munch in > PyPI > Box is also popular as it permits deeper nesting: https://pypi.python.org/pypi/python-box/ https://github.com/cdgriffith/Box

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

2017-11-29 Thread Daniel Moisset
As reference of prior art, there is https://pypi.python.org/pypi/munch in PyPI On 29 November 2017 at 05:52, Serhiy Storchaka wrote: > In 3.7 I have removed an old-deprecated plistlib.Dict. [1] Actually it > already was deprecated when the plistlib module was added to the

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

2017-11-29 Thread Serhiy Storchaka
In 3.7 I have removed an old-deprecated plistlib.Dict. [1] Actually it already was deprecated when the plistlib module was added to the regular stdlib in Python 2.6. 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