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 steven.daprano
Recipients steven.daprano, xuancong84
Date 2021-08-17.04:15:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629173749.25.0.934387001422.issue44930@roundup.psfhosted.org>
In-reply-to
Content
> Python 3 has removed the capability to create a list from a range.

That's incorrect. You can do `list(range(1,100,2))`. But generally, why create a list? range objects support many of the list APIs:

- iteration
- fast containment tests `x in range(1, 100, 2)`
- indexing (subscripts) and slicing
- reversal using a slice
- count and index methods


Range objects support the full sequence API, so why do you need to convert to a list?

    >>> from collections.abc import Sequence
    >>> isinstance(range(1, 100, 2), Sequence)
    True


For the unusual or rare cares where you do need a list, why do you need special syntax? Just call the list constructor.
History
Date User Action Args
2021-08-17 04:15:49steven.dapranosetrecipients: + steven.daprano, xuancong84
2021-08-17 04:15:49steven.dapranosetmessageid: <1629173749.25.0.934387001422.issue44930@roundup.psfhosted.org>
2021-08-17 04:15:49steven.dapranolinkissue44930 messages
2021-08-17 04:15:49steven.dapranocreate