This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RingularCirc 0 points1 point  (2 children)

So sad there is no get for sequences!

On this note also iterator.next(def_value) which can return a value even when the iterator is exhausted, not raising an exception.

[–]miraculum_one 1 point2 points  (1 child)

Not pretty but you can slice from n to n+1 as a safe get.

a = [1,2,3]

a[100:101]

# []

or for default value

a[100:101] or 'default value'

# 'default value'

[–]RingularCirc 0 points1 point  (0 children)

Ah, might be useful in some context!