On 24/09/2012 01:05, Tim Chase wrote:
On 09/23/12 18:52, Alec Taylor wrote:
You can always use a counter if you don't like our fancy for-each loops;

foolist = [1,24,24,234,23,423,4]
for i in xrange(len(foolist)):
     print foolist[i]

http://www.seas.upenn.edu/~lignos/py_antipatterns.html

The first one on the list of anti-patterns is doing exactly this.
Just don't.  Ewww.  Inefficient, ugly, and harder to read.

Part of learning to write in Python is, well, learning to write
*Python*, not {C,C++,Java,PHP}-in-Python.

-tkc


Maybe my mind is rather more warped than I thought it was, but my first impression was that foolist was a play on foolish.

I also like the anti-pattern on the link namely:-

for (index, value) in enumerate(alist):
    print index, value

Fancy wasting time, money and effort typing those unnecessary round brackets.

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to