trouble writing results to files
Neil Cerutti
horpner at yahoo.com
Wed Nov 29 10:46:32 EST 2006
On 2006-11-29, Roberto Bonvallet <Roberto.Bonvallet at cern.ch> wrote:
> Neil Cerutti wrote:
>> On 2006-11-29, Roberto Bonvallet <Roberto.Bonvallet at cern.ch> wrote:
>>> BTW, iterating over range(len(a)) is an anti-pattern in Python.
>>
>> Unless you're modifying elements of a, surely?
>
> enumerate is your friend :)
>
> for n, item in enumerate(a):
> if f(item):
> a[n] = whatever
I was going to bring it up but I had a brainfart about the order
of (n, item) in the tuple and was too lazy to look it up. ;-)
--
Neil Cerutti
More information about the Python-list
mailing list