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:
>
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(*
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
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
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
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
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
[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
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
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
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)()
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
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
> > [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
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
On 8/17/05, Anthony Baxter <[EMAIL PROTECTED]> wrote:
> If you _really_ want to call a local variable 'id' you can (but shouldn't).
Disagreed. The built-in namespace is searched last for a reason -- the
design is such that if you don't care for a particular built-in you
don't need to know about it
[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
___
I missed the discussion on this
(http://www.python.org/peps/pep-0309.html), but then 2.5 isn't out yet.
I think partial() misses an important use case of method getting, for
instance:
lst = ['A', 'b', 'C']
lst.sort(key=partialmethod('lower'))
Which sorts by lower-case. Of course you
Anthony Baxter wrote:
> Removing it entirely is gratuitous breakage, for a not very high payoff. If
> you _really_ want to call a local variable 'id' you can (but shouldn't).
> You also can't/shouldn't call a variable 'class', 'def', or 'len' -- but I
> don't see any movement to allow these...
Th
James Y Knight wrote:
> On Aug 17, 2005, at 2:55 PM, Timothy Fitz wrote:
>
>
>>On 8/16/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
>>
>>
>>>-0 The behavior of dir() already a bit magical. Python is much
>>>simpler
>>>to comprehend if we have direct relationships like dir() and vars()
>>>
20 matches
Mail list logo