loops

James Mills prologic at shortcircuit.net.au
Sat Oct 18 23:45:34 EDT 2008


On Sun, Oct 19, 2008 at 1:44 PM, James Mills
<prologic at shortcircuit.net.au> wrote:
> On Sun, Oct 19, 2008 at 1:30 PM, Steven D'Aprano
> <steve at remove-this-cybersource.com.au> wrote:
>> for x in (2**i for i in xrange(10)):
>>    print x
>
> This is by far the most concise solution I've seen so far.
> And it should never be about conserving code.
> Also, Python IS NOT C (to be more specific: Python
> is not a C-class language).

Also, if the OP is finding himself writing such manual
and mundane looking loops, he/she should reconsider
what it is he/she is doing. You would normally want
to iterate (vs. loop) over a sequence of items.

--JamesMills

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list