PEP 284, Integer for-loops
Tim Legant
tim-dated-1016242653.c3a0c9 at catseye.net
Fri Mar 8 20:37:32 EST 2002
James_Althoff at i2.com writes:
[...]
> I just did the same for a small section of our code. My quick little scan
> turned up 293 uses of [x]range. Most -- as in nearly all -- of them are in
> for-loops and *are* used in conjunction with the indices of collections.
>
> Our mileage might be different from others because our use of Jython is for
> large-scale, shipping, production-level, commercial applications rather
> than for small, throw-away scripts or core-language libraries. Also (as
> mentioned) we use Jython and have to deal with tables and other kinds of
> collections written in Java outside the scope of core C-Python. So I guess
> we lose.
Out of curiosity I ran a couple of quick greps over the TMDA source.
TMDA doesn't really fall into either of your "alternative" categories;
it's small, but definitely not throwaway and it's an application, not
a core library. It's a mail processor to eliminate SPAM. However,
it's pure Python; there's no integration with C or Java.
The results were that I found 52 or 53 'for' loops (scanned the
results of the grep by eye, since the word 'for' appears in comments
as well) and exactly no uses of [x]range at all.
So either Jason and I are significantly better than you and your team
at expressing ourselves naturally in Python <wink> or it's the need to
interface with Java that's forcing you to use integer indices all the
time. I'm betting big money on the latter.
Tim
More information about the Python-list
mailing list