Martin v. Löwis wrote: > Steven Bethard wrote: > >>I thought that: > >> operator.attrgetter() was for obj.attr > >> operator.itemgetter() was for obj[integer_index] > > > > > > My point exactly. If we're sticking to the same style, I would expect that > > for > > obj.method(*args, **kwargs) > > we would have something like: > > operator.methodcaller('method', *args, **kwargs) > > You might be missing one aspect of attrgetter, though. I can have > > f = operator.attrgetter('name', 'age') > > and then f(person) gives me (person.name, person.age). Likewise for > itemgetter(1,2,3). [snip] > I don't know what the common use for > attrgetter is: one or more attributes?
Well, in current Python code, I'd be willing to wager that it's one, no more, since Python 2.4 only supports a single argument to itemgetter and attrgetter. Of course, when Python 2.5 comes out, it's certainly possible that the multi-argument forms will become commonplace. I agree that an operator.methodcaller() shouldn't try to support multiple methods. OTOH, the syntax methodcall.method(*args, **kwargs) doesn't really lend itself to multiple methods either. STeVe -- You can wordify anything if you just verb it. --- Bucky Katt, Get Fuzzy _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com