Python for beginners or not? [was Re: syntax difference]

Neil Cerutti neilc at norwich.edu
Wed Jun 27 10:30:46 EDT 2018


On 2018-06-25, Alister <alister at 1> wrote:
> for i in range(len(list)): is a python anti-pattern it is almost a 100%
> guarantee that you are doing something wrong*
>
> *as with all rules of thumb there is probably at least 1
> exception that the python experts will now point out.

When you need look-ahead or similar inspection of more than the
current item. An alternative is a custom generator or iterator
that provides the window you need.

-- 
Neil Cerutti




More information about the Python-list mailing list