This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Isaac Morland
Recipients Isaac Morland, josh.r, steven.daprano
Date 2017-04-08.17:38:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491673092.24.0.0168359485034.issue30020@psf.upfronthosting.co.za>
In-reply-to
Content
What are the "other issues"?

As to the issue you raise here, that's why I use rename=True.

First create a type with an underscore attribute:

>>> t = namedtuple ('t', ['a', '1234'], rename=True)

(just an easy way of creating such a type; used of namedtuple specifically is admittedly a bit of a red herring)

Now create an object and illustrate its attributes:

>>> tt = t ('c', 'd')
>>> tt.a
'c'
>>> tt._1
'd'

Now use my modified attrgetter to get the attributes as a namedtuple:

>>> attrgetter ('a', '_1') (tt)
attrgetter(a='c', _1='d')
>>> 

And the example from the help, used in the test file I've already attached, illustrates that the dotted attribute case also works.

Essentially, my patch provides no benefit for attrgetter specified attributes that aren't valid namedtuple attribute names, but because of rename=True it still works and doesn't break anything.  So if you give "a" as an attribute name, the output will have an "a" attribute; if you give "_b" as an attribute name, the output will have an "_1" (or whatever number) attribute.  Similarly, it doesn't help with dotted attributes, but it doesn't hurt either.
History
Date User Action Args
2017-04-08 17:38:12Isaac Morlandsetrecipients: + Isaac Morland, steven.daprano, josh.r
2017-04-08 17:38:12Isaac Morlandsetmessageid: <1491673092.24.0.0168359485034.issue30020@psf.upfronthosting.co.za>
2017-04-08 17:38:12Isaac Morlandlinkissue30020 messages
2017-04-08 17:38:11Isaac Morlandcreate