Re: compare range objects

2011-10-23 Thread 88888 Dihedral
To compare two instances of objects defined by others in the same class or in derived classes from the same base class is an old problem in OOP. -- http://mail.python.org/mailman/listinfo/python-list

Re: compare range objects

2011-10-22 Thread rusi
On Oct 22, 10:51 pm, SigmundV wrote: > On Oct 22, 6:32 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote: > > > Sure. But the downside of sets is that, like lists, they are not lazy, > > Thank you for pointing this out. I agree that it's not a viable > alternative for large domains. St

Re: compare range objects

2011-10-22 Thread SigmundV
On Oct 22, 6:32 am, Steven D'Aprano wrote: > > Sure. But the downside of sets is that, like lists, they are not lazy, Thank you for pointing this out. I agree that it's not a viable alternative for large domains. Storing the bounds and the resolution should be enough. /Sigmund -- http://mail.py

Re: compare range objects

2011-10-22 Thread Steven D'Aprano
On Sat, 22 Oct 2011 05:32:44 +, Steven D'Aprano wrote: > On Fri, 21 Oct 2011 16:42:16 -0700, SigmundV wrote: > >> On Oct 21, 2:55 am, Yingjie Lan wrote: >>> >>> In simulation, one can use range objects to denote a discrete domain, >>> and domain comparison could be very useful. Not just equa

Re: compare range objects

2011-10-21 Thread Steven D'Aprano
On Fri, 21 Oct 2011 16:42:16 -0700, SigmundV wrote: > On Oct 21, 2:55 am, Yingjie Lan wrote: >> >> In simulation, one can use range objects to denote a discrete domain, >> and domain comparison could be very useful. Not just equality, but also >> things like if one domain is contained in another.

Re: compare range objects

2011-10-21 Thread SigmundV
On Oct 21, 2:55 am, Yingjie Lan wrote: > > In simulation, one can use range objects to denote a discrete domain, > and domain comparison could be very useful. Not just equality, but also > things like if one domain is contained in another. Can't sets [help(set)] be used for this? -- http://mail

Re: compare range objects

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 8:16 PM, Chris Angelico wrote: > Hmm. I wonder would slice objects be appropriate? They're comparable: > a=slice(1,10) b=slice(1,10) a==b > True > > They're not iterable though - not directly (but you could slice > range(maxint) down to size). You could possi

Re: compare range objects

2011-10-20 Thread alex23
On Oct 21, 12:16 pm, Chris Angelico wrote: > Hmm. I wonder would slice objects be appropriate? > They're not iterable though They're not hashable either, which kind of surprised me. -- http://mail.python.org/mailman/listinfo/python-list

Re: compare range objects

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:55 PM, Yingjie Lan wrote: > In simulation, one can use range objects to denote a discrete domain, > and domain comparison could be very useful. Not just equality, but also > things like if one domain is contained in another. > Hmm. I wonder would slice objects be approp

Re: compare range objects

2011-10-20 Thread Yingjie Lan
- Original Message - > From: Westley Martínez > To: python-list@python.org > Cc: > Sent: Friday, October 21, 2011 12:22 AM > Subject: Re: compare range objects > > There's already a discussion about this on python-ideas.  But somebody > please tell m

Re: compare range objects

2011-10-20 Thread 88888 Dihedral
The range() in python is an iterable generator that returns an object ref/id. The xrange() is different. -- http://mail.python.org/mailman/listinfo/python-list

Re: compare range objects

2011-10-20 Thread Ethan Furman
Ian Kelly wrote: On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder wrote: There's already a discussion about this on python-ideas. But somebody please tell me, why would you ever need to compare ranges? It could be useful if you're unit-testing a function that returns a range. Easy: list(range

Re: compare range objects

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder wrote: >> There's already a discussion about this on python-ideas.  But somebody >> please tell me, why would you ever need to compare ranges? > > It could be useful if you're unit-testing a function that returns a range. Easy: list(range1) == list(r

Re: compare range objects

2011-10-20 Thread Hans Mulder
On 20/10/11 18:22:04, Westley Martínez wrote: On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote: Hi, Is it possible to test if two range objects contain the same sequence of integers by the following algorithm in Python 3.2? 1. standardize the ending bound by letting it be the first

Re: compare range objects

2011-10-20 Thread Westley Martínez
On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote: > Hi,  > > Is it possible to test if two range objects contain the same sequence of > integers by the following algorithm in Python 3.2? > > 1. standardize the ending bound by letting it be the first excluded integer > for the given s

compare range objects

2011-10-20 Thread Yingjie Lan
Hi,  Is it possible to test if two range objects contain the same sequence of integers by the following algorithm in Python 3.2? 1. standardize the ending bound by letting it be the first excluded integer for the given step size. 2. compare the standardized starting bound, ending bound and step