Issue1990

classification
Title: attrgetter supports dotted access as of python 2.6
Type: behaviour Severity: normal
Components: Library Versions: 2.7a2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, zzzeek
Priority: Keywords:

Created on 2012-11-19.16:34:27 by zzzeek, last changed 2013-02-05.19:45:26 by fwierzbicki.

Messages
msg7529 (view) Author: mike bayer (zzzeek) Date: 2012-11-19.16:34:26
i.e.:

class Foo(object):
    class bar(object):
        bat = "hi"

from operator import attrgetter

print attrgetter("bar.bat")(Foo)

this is a pure Python workaround:

    def dottedgetter(attr):
        def g(obj):
            for name in attr.split("."):
                obj = getattr(obj, name)
            return obj
        return g
msg7623 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-05.19:45:26
This is fixed in the default branch - I'm not exactly sure when it was fixed :) The upcoming beta1 release will have the fix included.
History
Date User Action Args
2013-02-05 19:45:26fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg7623
2012-11-19 16:39:39fwierzbickisetnosy: + fwierzbicki
2012-11-19 16:34:27zzzeekcreate