[New-bugs-announce] [issue46312] range() function could accept slice() objects as parameters
yota moteuchi
report at bugs.python.org
Sun Jan 9 07:36:50 EST 2022
New submission from yota moteuchi <yota.news at gmail.com>:
This improvement proposal is close to : https://bugs.python.org/issue42956 and also detailed in https://stackoverflow.com/questions/13855288/turn-slice-into-range
to iterate over a slice, the recommended method seems to be :
s = slice(5,100,3)
for i in range(s.stop)[s] :
# do something
but if range() accepted directly a slice, it would dramatically improve the readability :
s = slice(5,100,3)
for i in range(s) :
# do something
and it could be convenient, especially inside the __getitem__ property. I'll try to make a quick patch to test...
----------
messages: 410143
nosy: yota moteuchi
priority: normal
severity: normal
status: open
title: range() function could accept slice() objects as parameters
type: enhancement
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46312>
_______________________________________
More information about the New-bugs-announce
mailing list