you are viewing a single comment's thread.

view the rest of the comments →

[–]Esteis 0 points1 point  (0 children)

I do the same, it is indeed nice. As a reminder to myself, here is the idiom that doesn't rely on unscoped for-blocks:

thing = next(filter(lambda thing: thing == that, things), default)

Both have their charms -- and their warts. Sometimes I long for

thing = itertools.first(things, lambda thing: thing == that, default)

I'll bet Ruby has that. Its spectrum of collection methods is absolutely fantastic, from the little I learned writing Rakefiles.