Message215788
> whatever compelled the developer to declare the named fields
> using _property seems to be ignored in the definition of __dict__.
What compelled the _property alias is that the user could name an attribute "property" which would cause a conflict if _property has not been renamed.
For example:
T = namedtuple('T', ['property', 'plant', 'equipment'])
would create the following field definitions:
property = _property(_itemgetter(0), doc='Alias for field number 0')
plant = _property(_itemgetter(1), doc='Alias for field number 1')
equipment = _property(_itemgetter(2), doc='Alias for field number 2')
Note, if we didn't use _property, the builtin property() would be shadowed.
The code for __dict__ occurs upstream (before the field definitions), so it is safe from redefinition:
@property
def __dict__(self):
'A new OrderedDict mapping field names to their values'
return OrderedDict(zip(self._fields, self)) |
|
Date |
User |
Action |
Args |
2014-04-09 00:55:22 | rhettinger | set | recipients:
+ rhettinger, Jim.Peterson |
2014-04-09 00:55:22 | rhettinger | set | messageid: <1397004922.05.0.60843731715.issue21181@psf.upfronthosting.co.za> |
2014-04-09 00:55:22 | rhettinger | link | issue21181 messages |
2014-04-09 00:55:20 | rhettinger | create | |
|