r/Python•
[deleted]

Is there a reason range literals never made it into python?

I can do a_list[1::2] but neither

for i in (1:100:2):
    print(fib(i))

nor

a_list[[5, 8, 16]]

although it works in numpy:

an_array[[5,6,8]]

I get that python3 is in core changes/syntax freeze, but when the thaw comes, is there at least a PEP for these?

edit: Also: I know that "there should be one way to do it", I would prefer that way were (1:100:2) rather than range(1, 100, 2), especially since the colon range syntax is already in the language.

edit: Found the old old PEP 204.

Posted Jul 10, 2012, 7:33 AM UTC · edited

24
Loading comments…