exterminate icon indicating copy to clipboard operation
exterminate copied to clipboard

Inspiration: allow iterating over lists to overrun

Open alexwlchan opened this issue 7 years ago • 0 comments

One of the advantages of Python over a language like C is that you can directly iterate over arrays. No more for (var i = 0; i <= my_list_length; i++) (or was it i < my_list_length ?), just do for i in my_list. No risk of reading off the end of an array.

…unless, of course, some dastardly person were to overwrite the __iter__() method on your list that overran the end of the list. But who would do that?

(You could so something similar for strings, by having them continue until you "find" a null terminator.)

alexwlchan avatar Aug 25 '17 19:08 alexwlchan