range() is not the best way to check range?

K.S.Sreeram sreeram at tachyontech.net
Mon Jul 17 23:12:26 EDT 2006


Summercoolness at gmail.com wrote:
> so if i change the line
>     if i in range (0, 10000):
> to
>     if i >= 0 and i < 10000:
[snip;]
> is there an alternative use of range() or something similar that can
> be as fast?


you've found that alternative yourself! just use the comparison operators...

in fact, you can write a little more compact as:
    if 0 <= i < 10000 :


[sreeram;]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20060718/f341f50c/attachment.sig>


More information about the Python-list mailing list