[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-02-23 Thread Georg Brandl
Georg Brandl added the comment: Committed in r61027. -- status: open -> closed __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing li

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: FWIW, Georg's patch works here. Perhaps there should be a test for unicode attribute names since it is special-cased in the patch. -- nosy: +pitrou __ Tracker <[EMAIL PROTECTED]> ___

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-19 Thread Georg Brandl
Georg Brandl added the comment: Attaching another patch that doesn't create a list of strings every time the attrgetter is called. Also includes docs. -- nosy: +georg.brandl Added file: http://bugs.python.org/file9236/attrgetter-2.diff __ Tracker <[EMAIL

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-15 Thread Scott Dial
Scott Dial added the comment: Mea culpa, the original patch I attached here has an obvious duplication of code in test_operator.py. I've attached an updated patch to make life easier on the commiter. Added file: http://bugs.python.org/file9175/getattrchaser.diff

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Scott Dial
Scott Dial added the comment: The attached patch provides for the functionality requested. I've updated the docstring of attrgetter related to this new feature and have updated test_operator accordingly. Added file: http://bugs.python.org/file9169/getattrchaser.diff

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: I think Barry's proposal is fine. If we need to update the docs, then so be it. His proposal adds useful functionality while keeping readability and clarity. FWIW, the getattr() explanation in the docs already needs to be expanded to cover the multi-argumen

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: I'm not /personally/ concerned with the breakage because practicality beats purity, and I don't want to use lambda because it's slower. I've never used operator.attrgetter() outside the specific use case of sorted() and list.sort() so I'd like to make it able t

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Scott Dial
Scott Dial added the comment: I want to clarify that the proposed change would break: operator.attrgetter(foo)(bar) == getattr(bar, foo) Which is the documented intent of the operator module: "This module exports a set of functions implemented in C corresponding to the intrinsic operators of Py

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Martin v. Löwis
Martin v. Löwis added the comment: What's wrong with sorted(seq, key=lambda v:v.person.displayname) -- nosy: +loewis __ Tracker <[EMAIL PROTECTED]> __

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Hey Guido, can I borrow the keys to the time machine to get this into Python 2.5.0? :) __ Tracker <[EMAIL PROTECTED]> __ _

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: I don't even mind if you *write* the patch :) I actually haven't had time yet to hack it up, but I just reached my threshold of tolerance so I had to at least report the bug. I think it's always a good idea to review patches before they go in anyway, so if I w

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: Mind if I take a look at the patch before it goes in? -- nosy: +rhettinger __ Tracker <[EMAIL PROTECTED]> __ __

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Guido van Rossum
Guido van Rossum added the comment: Fair enough. Fine with me then. __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing list Unsubscribe: ht

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Unfortunately, that already has different, existing (and IMHO less useful) semantics. :( __ Tracker <[EMAIL PROTECTED]> __ ___

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Guido van Rossum
Guido van Rossum added the comment: How about a slight change to the proposed API, and make it a varargs function? E.g. operator.attrgetter('person', 'displayname') This would avoid the need to parse the argument. -- nosy: +gvanrossum __ Tracker <[EM

[issue1826] operator.attrgetter() should accept dotted attribute paths

2008-01-14 Thread Barry A. Warsaw
New submission from Barry A. Warsaw: operator.attrgetter() is neutered because it only accepts a single attribute name, but it would really be much more useful if it accepted, and followed a dotted attribute path, e.g.: sorted(seq, key=operator.attrgetter('person.displayname')) Of course attrge