On Tue, Jun 11, 2013 at 8:42 AM, Jason Orendorff <[email protected]>wrote:
> Please look at any Python codebase. The right-hand side of a for loop is > most often just an identifier or simple expression naming a collection. You > will see a few calls to enumerate(), .items(), and so on, but they do not > predominate. Sometimes it's a list literal. > > > I will quantify this later today. > In case I don't get to this, here is the code you can use: https://gist.github.com/jorendorff/5757221 It's easy to run on any Python codebase. In the Python 3.3.1 distribution, for example, only about 12% of for loops require an explicit indication of what kind of iterator is wanted. That is, the default is used about 88% of the time. 49.0% - N - just an identifier 15.0% - R - call to range() 15.5% - A - an attribute-expression, like self.parts 6.4% - I - call to .items() or .iteritems() 4.2% - L - literal string, tuple, list, or set 2.7% - E - call to enumerate() 1.3% - K - call to .keys() or .iterkeys() 1.0% - V - call to .values() or .itervalues() 4.9% - O - everything else (examples: module.split('.')[1:], dirs[:], args[1:], fixers[node.type]) -j
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

