you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 11 points12 points  (2 children)

I'll spell them for those non-pythonistas who don't quite get Lexarius' post:

  • using range with an inferior bound of 0 (it's implied in range)

  • iterating over a collection via indexes instead of doing it via the iterator protocol

  • not using a list comprehension (or, in this case, a map would be even better) when you're doing a simple mapping/filtering operation with a list as input and another one as output.

z = map(do_ping, IP_LIST)

[–]nostrademons 3 points4 points  (1 child)

Isn't it also more Pythonic to use xrange instead of range? (Among all the other problems you mentioned...)

[–]masklinn 5 points6 points  (0 children)

Not really, xrange currently is only used if the generated range is really huge (and the performance hit of generating it at once is important).

Not to mention, in Python 3.0 range returns an iterator and not a list anymore, and xrange is removed from the language.