Re: ordering with duck typing in 3.1

2012-04-09 Thread Neil Cerutti
On 2012-04-07, Jon Clements jon...@googlemail.com wrote: Any reason you can't derive from int instead of object? You may also want to check out functions.total_ordering on 2.7+ functools.total_ordering I was temporarily tripped up by the aforementioned documentation, myself. -- Neil Cerutti

Re: ordering with duck typing in 3.1

2012-04-09 Thread Jon Clements
On Monday, 9 April 2012 12:33:25 UTC+1, Neil Cerutti wrote: On 2012-04-07, Jon Clements jon...@googlemail.com wrote: Any reason you can't derive from int instead of object? You may also want to check out functions.total_ordering on 2.7+ functools.total_ordering I was temporarily

ordering with duck typing in 3.1

2012-04-07 Thread andrew cooke
hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators but i am seeing assert 2 three E

Re: ordering with duck typing in 3.1

2012-04-07 Thread Thomas Rachel
Am 07.04.2012 14:23 schrieb andrew cooke: class IntVar(object): def __init__(self, value=None): if value is not None: value = int(value) self.value = value def setter(self): def wrapper(stream_in, thunk): self.value = thunk()

Re: ordering with duck typing in 3.1

2012-04-07 Thread Rob Williscroft
andrew cooke wrote in news:33019705.1873.1333801405463.JavaMail.geo-discussion-forums@ynmm9 in gmane.comp.python.general: hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons in general, __lt__() and __eq__() are

Re: ordering with duck typing in 3.1

2012-04-07 Thread John O'Hagan
On Sat, 7 Apr 2012 05:23:25 -0700 (PDT) andrew cooke and...@acooke.org wrote: hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons in general, __lt__() and __eq__() are sufficient, if you want the conventional

Re: ordering with duck typing in 3.1

2012-04-07 Thread mwilson
Thomas Rachel wrote: Am 07.04.2012 14:23 schrieb andrew cooke: class IntVar(object): def __init__(self, value=None): if value is not None: value = int(value) self.value = value def setter(self): def wrapper(stream_in, thunk):

ordering with duck typing in 3.1

2012-04-07 Thread Jon Clements
Any reason you can't derive from int instead of object? You may also want to check out functions.total_ordering on 2.7+ -- http://mail.python.org/mailman/listinfo/python-list