Mike Klaas wrote:
> On 18-Jan-08, at 1:37 PM, Lars Immisch wrote:
>>
>> I like cmp, too. I've looked through my code, and I've only used it in
>> script-ish circumstances, but here is an example that sorts a list of
>> files by modification date:
>>
>> def cmp_mtime(f, g):
>> """Too much for a
On 18-Jan-08, at 1:37 PM, Lars Immisch wrote:
>
> I like cmp, too. I've looked through my code, and I've only used it in
> script-ish circumstances, but here is an example that sorts a list of
> files by modification date:
>
> def cmp_mtime(f, g):
> """Too much for a lambda for my tastes."""
>
David A. Wheeler wrote:
> Bill Janssen:
>> I'm a bit baffled here; I find cmp() fairly handy in writing sort routines...
>> Is there a better / newer / official way of doing this? If not, isn't
>> "cmp()" still useful to have around?
>
> I agree with you - I find cmp() useful, and I notice that so
Bill Janssen:
>I'm a bit baffled here; I find cmp() fairly handy in writing sort routines...
>Is there a better / newer / official way of doing this? If not, isn't
>"cmp()" still useful to have around?
I agree with you - I find cmp() useful, and I notice that some others do too.
E.G., Adam Olson s
On 9-Jan-08, at 11:41 AM, Oleg Broytmann wrote:
> On Wed, Jan 09, 2008 at 11:34:59AM -0800, Brett Cannon wrote:
>> On Jan 9, 2008 11:34 AM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
>>>newlist = oldlist.sort(key=lambda v: v.attr_x)
>>
>> And don't forget about operator.attrgetter().
>
>I d
On Wed, Jan 09, 2008 at 11:34:59AM -0800, Brett Cannon wrote:
> On Jan 9, 2008 11:34 AM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> >newlist = oldlist.sort(key=lambda v: v.attr_x)
>
> And don't forget about operator.attrgetter().
I don't like it for the task. To use I need to import opera
On Jan 9, 2008 11:34 AM, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> On Wed, Jan 09, 2008 at 11:26:52AM -0800, Bill Janssen wrote:
> > I'm a bit baffled here; I find cmp() fairly handy in writing sort
> > routines:
> >
> >newlist = oldlist.sort(lambda v1, v2: cmp(v1.attr_x, v2.attr_x))
> >
> >
On Wed, Jan 09, 2008 at 11:26:52AM -0800, Bill Janssen wrote:
> I'm a bit baffled here; I find cmp() fairly handy in writing sort
> routines:
>
>newlist = oldlist.sort(lambda v1, v2: cmp(v1.attr_x, v2.attr_x))
>
> Is there a better / newer / official way of doing this?
newlist = oldlist.s
Steve Bethard writes:
> On Jan 8, 2008 3:55 PM, Brett Cannon <[EMAIL PROTECTED]> wrote:
> > On Jan 8, 2008 2:41 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> > > list.sort() and built-in sorted() are the least of our problems: even
> > > though the API uses cmp, the implementation actually only
On Jan 9, 2008 12:04 AM, Mark Summerfield <[EMAIL PROTECTED]> wrote:
> I'm using this as a class decorator that fills in "missing" comparisons:
>
> def complete_comparisons(cls):
> class CompleteComparisonsError(Exception): pass
>
> if hasattr(cls.__lt__, "__objclass__"): # i.e. < inherited
Dnia 09-01-2008, Śr o godzinie 01:49 +0100, Christian Heimes pisze:
> You could write and implement a PEP about exposing the tp_richcompare
> slot to Python code.
How is it better than separate __eq__, __lt__ etc.? In most cases the
rich comparison starts with dispatching on the operation and tre
On 2008-01-09, Christian Heimes wrote:
> Guido van Rossum wrote:
> > That's a different issue altogether (and your wish is not likely going
> > to be granted unless you write a PEP).
>
> You could write and implement a PEP about exposing the tp_richcompare
> slot to Python code.
>
> import sys
>
>
Guido van Rossum wrote:
> That's a different issue altogether (and your wish is not likely going
> to be granted unless you write a PEP).
You could write and implement a PEP about exposing the tp_richcompare
slot to Python code.
import sys
class Example:
def __richcmp__(self, other: object,
That's a different issue altogether (and your wish is not likely going
to be granted unless you write a PEP).
On Jan 8, 2008 4:23 PM, hashcollision <[EMAIL PROTECTED]> wrote:
> +1 from me too if you only need to define __lt__ and __eq__ and __le__ and
> __gt__, etc, will default to that. If it dos
+1 from me too if you only need to define __lt__ and __eq__ and __le__ and
__gt__, etc, will default to that. If it dosn't default to those, I feel
that one would need to write too many functions.
On Jan 8, 2008 7:12 PM, Steven Bethard <[EMAIL PROTECTED]> wrote:
> On Jan 8, 2008 3:55 PM, Brett Ca
On Jan 8, 2008 3:55 PM, Brett Cannon <[EMAIL PROTECTED]> wrote:
> On Jan 8, 2008 2:41 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> > list.sort() and built-in sorted() are the least of our problems: even
> > though the API uses cmp, the implementation actually only ever uses
> > '<'; and the pr
On Jan 8, 2008 2:41 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> list.sort() and built-in sorted() are the least of our problems: even
> though the API uses cmp, the implementation actually only ever uses
> '<'; and the preferred API is to use the 'key' argument instead of
> passing a compare
list.sort() and built-in sorted() are the least of our problems: even
though the API uses cmp, the implementation actually only ever uses
'<'; and the preferred API is to use the 'key' argument instead of
passing a compare function; that's much more efficient.
Maybe we should retire the compare fu
Ok, I do see your point, but how would one pass in a custom comparison
function to sorted?
On Jan 7, 2008 11:55 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On Jan 7, 2008 8:48 PM, hashcollision <[EMAIL PROTECTED]> wrote:
> >
> >
> > > But the biggest thing missing is precise semantics. Say
On Jan 7, 2008 8:48 PM, hashcollision <[EMAIL PROTECTED]> wrote:
>
>
> > But the biggest thing missing is precise semantics. Saying "exactly
> > the same semantics as with Python 2.5" doesn't cut it (those semantics
> > are incredibly hairy and sometimes surprising, and their
> > implementation was
>
> But the biggest thing missing is precise semantics. Saying "exactly
> the same semantics as with Python 2.5" doesn't cut it (those semantics
> are incredibly hairy and sometimes surprising, and their
> implementation was a nightmare -- I've rarely been as relieved as when
> I was able to cut th
On Jan 5, 2008 10:40 PM, hashcollision <[EMAIL PROTECTED]> wrote:
> David A. Wheeler has already written a draft PEP, which can be found here:
> http://www.dwheeler.com/misc/pep-cmp.txt.
Thanks, I'd missed that.
But alas, it's a bit short on the motivation for rich comparisons. For
example it fai
David A. Wheeler has already written a draft PEP, which can be found here:
http://www.dwheeler.com/misc/pep-cmp.txt.
___
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.o
On Jan 4, 2008 12:18 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> In the past some folks have been pushing for the resurrection of (some
> form of) __cmp__, which is currently removed from Py3k (except for
> some remnants which we'll clean up in due time).
>
> I'd like to get closure on this
In the past some folks have been pushing for the resurrection of (some
form of) __cmp__, which is currently removed from Py3k (except for
some remnants which we'll clean up in due time).
I'd like to get closure on this issue. If someone volunteers within a
week to write a PEP, I'll give them a mon
25 matches
Mail list logo