how many nested for can we utilize?

Patrol Sun sunp1028 at gmail.com
Sun Aug 17 20:57:46 EDT 2008


Of course We needn't 100 levels,but I use the exec function can concise the
code. See the attachment.

2008/8/17 Fredrik Lundh <fredrik at pythonware.com>

> Nick Dumas wrote:
>
> A good quote I read (I can't remember who it was from, though) is "If
>> you need more than three levels of indentation, then something is
>> seriously wrong with your code." Possibly Guido himself? Anyway. If
>> you've got 100 levels of for, you're probably making things way harder
>> than they need to be.
>>
>
> assuming 100 levels of for and 2 items in each sequence, you'll end up with
> 1267650600228229401496703205376 iterations through the inner loop.  assuming
> each iteration takes a picosecond, it'll take approx 40 billion years to run
> the program.
>
> </F>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080818/90d14598/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 052.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20080818/90d14598/attachment-0001.ksh>


More information about the Python-list mailing list