This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients mdk, ncoghlan, rhettinger, seluj78, serhiy.storchaka, steven.daprano
Date 2018-11-21.08:39:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1542789547.36.0.788709270274.issue35200@psf.upfronthosting.co.za>
In-reply-to
Content
As a teacher, I think the proposal makes us worst off.  It is far easier and more useful at the interactive prompt to use list() rather than print() to show ranges:

    >>> list(range(10))
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    >>> list(range(2, 10))
    [2, 3, 4, 5, 6, 7, 8, 9]
    >>> list(range(2, 10, 3))
    [2, 5, 8]

If you do the same thing with print(), it takes an additional character ("print" vs "list"), it creates a new source of confusion (str vs repr), and it doesn't generalize to other iterators like enumerate(), reversed(), and generators.

Also, the various ideas listed for a possible new __str__ are all awkward or mysterious for some inputs (empty ranges, short ranges, etc).

FWIW, I teach this topic every week.  Presenting with list(range(...)) is less convenient than with the Python 2.7 version, but it works out just fine in practice and nicely sets the stage for covering set(iterable), tuple(iterable), dict.fromkeys(iterable), etc.

I'm opposed the this proposal because I think it will create more teaching difficulties than it solves.
History
Date User Action Args
2018-11-21 08:39:07rhettingersetrecipients: + rhettinger, ncoghlan, steven.daprano, serhiy.storchaka, mdk, seluj78
2018-11-21 08:39:07rhettingersetmessageid: <1542789547.36.0.788709270274.issue35200@psf.upfronthosting.co.za>
2018-11-21 08:39:07rhettingerlinkissue35200 messages
2018-11-21 08:39:07rhettingercreate