[issue9896] Introspectable range objects
Éric Araujo mer...@netwok.org added the comment: I think this is ready for commit. -- nosy: +smarnach ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 4643be424293 by Benjamin Peterson in branch 'default': add introspection to range objects (closes #9896) http://hg.python.org/cpython/rev/4643be424293 -- nosy: +python-dev resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Ezio Melotti ezio.melo...@gmail.com added the comment: See also #13200. -- nosy: +ezio.melotti -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Éric Araujo mer...@netwok.org added the comment: Looks good, apart from the use of assertEquals (deprecated in favor of assertEqual). I’d also remove “merely” from the doc addition. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Daniel Urban urban.dani...@gmail.com added the comment: Thanks, I've corrected my patch. -- Added file: http://bugs.python.org/file21733/range_attrs_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Daniel Urban urban.dani...@gmail.com added the comment: Now that the moratorium has already ended, I'll try again. I've updated the patch. It seems, that this idea has already came up in the past: Guido in msg70525 said: I also think ranges should be introspectable, exposing their start, stop and step values just like slice objects. A possible use case: the range slicing logic is quite complex (with a lot of corner cases). It would be good, if this logic would be accessible from Python code, for example to compute a slice of a slice-like-thing. Currently slicing a range object returns another range object, but there is no way to determine the bounds of this new object. -- versions: +Python 3.3 -Python 3.2 Added file: http://bugs.python.org/file21692/range_attrs_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Antoine Pitrou pit...@free.fr added the comment: One other thought. If there is a perceived need, I would rather an alternate approach that unifies a language a bit by letting range() expose its arguments as a slice and modify its input to accept a slice. This sounds like an obscure complication to me. A range is not a slice and I don't see the point of trying to bridge both concepts. It is even more YAGNI than the original request. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Terry J. Reedy tjre...@udel.edu added the comment: Range objects are new in 3.0; they supersede 2.x xrange objects, which are perhaps 10 years old. I do not remember that xrange objects had such attributes. On the other hand, I believe there were requests. The request, with either implementation, seems reasonable in that range objects could be regarded as iterable slice objects. The differences are that range objects have __getitem__, __iter__, and __reversed__ special methods while slice objects have start, stop, and stop real-only attributes and the indices method. (I could not really understand the last from the doc; I had to experiment.) Starting fresh, we might do with just one class instead of two. I guess this makes me +0.3 at the moment. -- nosy: +terry.reedy stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Daniel Urban urban.dani...@gmail.com added the comment: What is the use case for this? The basic idea was, that in Python almost everything is introspectable, so why range objects aren't. It was pretty straightforward to implement it, so I've done it (actually when I was working on rangeobject.c, I was surprised to see that these members aren't available from python code). But if this isn't needed, I'm absolutely ok with that. I think this would be a nice to have feature, but of course not necessary. Also, if it violates the moratorium (I don't know), then of course this sould be at least postponed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
New submission from Daniel Urban urban.dani...@gmail.com: The attached patch adds the start, stop and step members to range objects, corresponding the contructor arguments. The patch also include tests and documentation changes. -- components: Interpreter Core files: range_attrs.diff keywords: patch messages: 116824 nosy: durban priority: normal severity: normal status: open title: Introspectable range objects type: feature request versions: Python 3.2 Added file: http://bugs.python.org/file18922/range_attrs.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: I don't see anything wrong with this idea, but I don't really see a need for it either. AFAICT, this has never been requested in the 20 years that range() has been in Python. This is probably YAGNI. It may also be in violation of the language moratorium (it's one more thing that other implementations would have to mirror). -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: One other thought. If there is a perceived need, I would rather an alternate approach that unifies a language a bit by letting range() expose its arguments as a slice and modify its input to accept a slice. range(0, 20, 2).slice slice(0, 20, 20) range(_) range(0, 20, 2) s = range(0, 20, 2).slice s.start 0 s.stop 20 s.step 2 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9896] Introspectable range objects
Mark Lawrence breamore...@yahoo.co.uk added the comment: What is the use case for this? -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com