[Python-ideas] Enhancing range object string displays
Chris Angelico
rosuav at gmail.com
Mon Nov 19 21:22:16 EST 2018
More information about the Python-ideas mailing list
Mon Nov 19 21:22:16 EST 2018
- Previous message (by thread): [Python-ideas] Enhancing range object string displays
- Next message (by thread): [Python-ideas] Enhancing range object string displays
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Nov 20, 2018 at 1:10 PM Steven D'Aprano <steve at pearwood.info> wrote: > > On Mon, Nov 19, 2018 at 05:09:25PM -0800, danish bluecheese wrote: > > I think it is kind of useless effort. If somebody using range() then > > probably knows about it. > > For experienced users, sure, but this is an enhancement to help > beginners who may be confused by the half-open end points. > > Even non-beginners may find it nice to be able to easily see the end > points when the step size is not 1. > > If range objects had this, I'd use it in the REPL to check the end > points. Sure, I could convert to a list and take a slice, but giving the > object a nicer print output makes less work for the user. > I'm a fairly experienced Python programmer, and I still just fire up a REPL to confirm certain uses of range() with steps. What would it be like if the string form looked like this: >>> range(1, 30, 3) range([1, 4, 7, ..., 25, 28]) In theory, this could actually be made legal, and could be a cool feature for an enhanced REPL to support. (All you have to do is define 'range' as a function that checks if it's been given a list, and if not, passes it on unchanged.) Whether this form or the original, I think this would be an improvement. ChrisA
- Previous message (by thread): [Python-ideas] Enhancing range object string displays
- Next message (by thread): [Python-ideas] Enhancing range object string displays
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list