New submission from yota moteuchi <yota.n...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue46312>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to