[issue10489] configparser: remove broken `__name__` support

Łukasz Langa report at bugs.python.org
Sun Nov 21 15:00:38 CET 2010


Łukasz Langa <lukasz at langa.pl> added the comment:

Committed in rev 86638. A public API for getting the name of the section from a SectionProxy instance was introduced in 86639. This is useful because you can assing a section proxy to a variable and pass it around:

>>> from configparser import SafeConfigParser
>>> parser = SafeConfigParser()
>>> parser.read_string("""
... [section1]
... value = A
... value2 = B
... 
... [section2]
... value = C
... value2 = D
... """)
>>> section1 = parser['section1']
>>> section1['value']
'A'
>>> section1.name
'section1'
>>> section2 = parser['section2']
>>> section2['value']
'C'
>>> section2.name
'section2'
>>> section2.name = 'cannot do that, this attribute is read-only on a SectionProxy'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: can't set attribute

----------
resolution:  -> accepted
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10489>
_______________________________________


More information about the Python-bugs-list mailing list