Message399708
> 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. |
|
Date |
User |
Action |
Args |
2021-08-17 04:15:49 | steven.daprano | set | recipients:
+ steven.daprano, xuancong84 |
2021-08-17 04:15:49 | steven.daprano | set | messageid: <1629173749.25.0.934387001422.issue44930@roundup.psfhosted.org> |
2021-08-17 04:15:49 | steven.daprano | link | issue44930 messages |
2021-08-17 04:15:49 | steven.daprano | create | |
|