Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

> 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.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44930>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to