Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Mark Summerfield
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 > >

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Marcin ‘Qrczak’ Kowalczyk
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

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Guido van Rossum
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

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Bill Janssen
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

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Oleg Broytmann
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

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Brett Cannon
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)) > > > >

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Oleg Broytmann
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

Re: [Python-3000] Need closure on __cmp__ removal

2008-01-09 Thread Mike Klaas
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

[Python-3000] PEP 3116 question

2008-01-09 Thread hashcollision
>From PEP 3116: "BufferedRandom implementation is for all random-access objects, whether they are read-only, write-only, or *read-write*." (emphasis mine) However, from the pseudo-code for open(), "if reading + writing + appending > 1: raise ValueError("can't have read/write/append mode at once

Re: [Python-3000] PEP 3116 question

2008-01-09 Thread Christian Heimes
hashcollision wrote: >>From PEP 3116: "BufferedRandom implementation is for all random-access > objects, whether they are read-only, write-only, or *read-write*." > (emphasis mine) However, from the pseudo-code for open(), > "if reading + writing + appending > 1: > raise ValueError("can't have