Enumerating in Python for the Rubyist

While there are similarities between Python and Ruby that make the transition from one to the other not a particularly difficult one, there are also some vexing differences — lack of enumerables in Python being one.

This is, of course, not a comprehensive list Python equivalents for all of Ruby’s enumerables, but some of my more frequently used. In Python, it typically comes down to list comprehension, which can be very elegant, though there are some built-in functions.

.each