Re: [Python-Dev] PEP 309: Partial method application

2005-08-19 Thread Martin v. Löwis
Josiah Carlson wrote: > Steven Bethard <[EMAIL PROTECTED]> wrote: > >>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. > > > But that's OK, we d

Re: [Python-Dev] PEP 309: Partial method application

2005-08-19 Thread Raymond Hettinger
[Steven Bethard] > > 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. [Josiah Carlson] > But that's OK, we don't want to be calling multiple

Re: [Python-Dev] PEP 309: Partial method application

2005-08-19 Thread Josiah Carlson
Steven Bethard <[EMAIL PROTECTED]> wrote: > 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. But that's OK, we don't want to be calling multiple

Re: [Python-Dev] PEP 309: Partial method application

2005-08-19 Thread Steven Bethard
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)

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Martin v. Löwis
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: >

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Steven Bethard
Josiah Carlson wrote: > Steven Bethard <[EMAIL PROTECTED]> wrote: > > If we're going to move away from the itemgetter() and attrgetter() > > style, then we should be consistent about it and provide a solution > > (or solutions) that answers all of these problems: > > obj.attr > > obj.attr(*

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Josiah Carlson
Steven Bethard <[EMAIL PROTECTED]> wrote: > > Martin v. Löwis wrote: > > So I would propose the syntax > > > > lst.sort(key=virtual.lower) # where virtual is functional.virtual > > Shane Hathaway wrote: > > class virtual: > > def __getattr__(self, name): > > return lambda obj: g

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Brett Cannon
On 8/18/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Brett Cannon wrote: > > Oh, when should we think of putting reduce into functional? I > > remember this was discussed when it was realized reduce was the only > > functional built-in that is not covered by itertools or listcomps. > > I expect

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Nick Coghlan
Brett Cannon wrote: >>>What I think you want is not a partial method, instead, you want to >>>turn a method into a standard function, and in a 'virtual' way. >>> >>>So I would propose the syntax >>> >>> lst.sort(key=virtual.lower) # where virtual is functional.virtual >> >>I like this, but would h

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Steven Bethard
Martin v. Löwis wrote: > So I would propose the syntax > > lst.sort(key=virtual.lower) # where virtual is functional.virtual Shane Hathaway wrote: > class virtual: > def __getattr__(self, name): > return lambda obj: getattr(obj, name)() > virtual = virtual() I think (perhaps beca

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Ian Bicking
Brett Cannon wrote: >>>What I think you want is not a partial method, instead, you want to >>>turn a method into a standard function, and in a 'virtual' way. >>> >>>So I would propose the syntax >>> >>> lst.sort(key=virtual.lower) # where virtual is functional.virtual >> >>I like this, but would h

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Raymond Hettinger
[Guido] > They feel related to attrgetter more than to partial. That suggests operator.methodcall() ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Brett Cannon
On 8/18/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 8/18/05, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > As for the more general proposal: -1 on more places to pass strings to > > denote method/function/class names. These are ugly to type. > > Agreed. > > > What I think you want is

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Guido van Rossum
On 8/18/05, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > As for the more general proposal: -1 on more places to pass strings to > denote method/function/class names. These are ugly to type. Agreed. > What I think you want is not a partial method, instead, you want to > turn a method into a stan

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Shane Hathaway
Martin v. Löwis wrote: > So I would propose the syntax > > lst.sort(key=virtual.lower) # where virtual is functional.virtual Ooh, may I say that idea is interesting! It's easy to implement, too: class virtual: def __getattr__(self, name): return lambda obj: getattr(obj, name)()

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Martin v. Löwis
Ian Bicking wrote: > > lst = ['A', 'b', 'C'] > lst.sort(key=partialmethod('lower')) > > Which sorts by lower-case. Of course you can use str.lower, except > you'll have unnecessarily enforced a type (and excluded Unicode). So > you are left with lambda x: x.lower(). For this specif

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Ian Bicking
Raymond Hettinger wrote: instance: lst = ['A', 'b', 'C'] lst.sort(key=partialmethod('lower')) >>> >>>We've already got one: >>> >>> lst.sort(key=operator.attrgetter('lower')) >> >>Doesn't that just sort on the str.lower or unicode.lower method >> object? > > My mis

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Raymond Hettinger
> > [Ian Bicking] > > > I think partial() misses an important use case of method getting, for > > > instance: > > > > > > lst = ['A', 'b', 'C'] > > > lst.sort(key=partialmethod('lower')) > > > > We've already got one: > > > >lst.sort(key=operator.attrgetter('lower')) > > Doesn't

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Steven Bethard
Raymond Hettinger wrote: > [Ian Bicking] > > I think partial() misses an important use case of method getting, for > > instance: > > > > lst = ['A', 'b', 'C'] > > lst.sort(key=partialmethod('lower')) > > We've already got one: > >lst.sort(key=operator.attrgetter('lower')) Doesn't

Re: [Python-Dev] PEP 309: Partial method application

2005-08-18 Thread Raymond Hettinger
[Ian Bicking] > I think partial() misses an important use case of method getting, for > instance: > > lst = ['A', 'b', 'C'] > lst.sort(key=partialmethod('lower')) We've already got one: lst.sort(key=operator.attrgetter('lower')) Raymond ___