Re:我们可以使用多少嵌套? [英] Re: how many nested for can we utilize?

查看:73
本文介绍了Re:我们可以使用多少嵌套?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Patrol Sun写道:

Patrol Sun wrote:


当我使用20时,SystemError:太多静态嵌套块

当我使用时100 for,IndentationError:太多级别的缩进

如何处理这些错误?
when I use 20 for ,"SystemError: too many statically nested blocks"
When I use 100 for ,"IndentationError: too many levels of indentation"
How to handle these errors?



那你为什么要尝试嵌套20或100个for-in循环呢?


< / F>

so why exactly are you trying to nest 20 or 100 for-in loops?

</F>

推荐答案

----- BEGIN PGP签名消息-----

哈希:SHA1


我读过的一句好话(不记得是谁),如果

你需要三个以上的缩进级别,然后你的代码严重错误了。

严重错误。可能是圭多自己?无论如何。如果

你有100个级别,你可能会比他们需要的更加努力。




Fredrik Lundh写道:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.

Fredrik Lundh wrote:

Patrol Sun写道:
Patrol Sun wrote:

>当我使用20时for,SystemError:太多静态嵌套块
当我使用100时,IndentationError:太多级别的缩进
如何处理这些错误?
>when I use 20 for ,"SystemError: too many statically nested blocks"
When I use 100 for ,"IndentationError: too many levels of indentation"
How to handle these errors?



那你为什么要尝试嵌套20或100个for-in循环呢?


< / F>


so why exactly are you trying to nest 20 or 100 for-in loops?

</F>



----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.9(MingW32)

评论:将GnuPG与Mozilla一起使用 - http://enigmail.mozdev.org


iEYEARECAAYFAkioM70ACgkQLMI5fndAv9jBhgCeM5hjNaAtlD osJq1DSZyPnBcL

7NYAoKKwnSdR20YDGXvjpAP8KUWfw / rl

= PajF

----- END PGP SIGNATURE -----

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkioM70ACgkQLMI5fndAv9jBhgCeM5hjNaAtlD osJq1DSZyPnBcL
7NYAoKKwnSdR20YDGXvjpAP8KUWfw/rl
=PajF
-----END PGP SIGNATURE-----


Nick Dumas写道:
Nick Dumas wrote:

我读过的一句好话(我可以''但是记住它是来自哪个,但是如果

你需要超过三个级别的缩进,那么你的代码就会出现严重错误。可能是圭多自己?无论如何。如果

你有100个等级,那么你可能会比他们需要的更加努力。
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.



假设每个序列有100个等级和2个项目,你最终将通过内循环1267650600228229401496703205376迭代获得


假设每次迭代需要一个皮秒,运行程序需要大约40亿美元。


< ; / F>

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>


On Sun,2008年8月17日16:39:26 +0200,Fredrik Lundh写道:
On Sun, 17 Aug 2008 16:39:26 +0200, Fredrik Lundh wrote:

>我读过的一句好话(我不记得是谁来的)是如果
你需要超过三个级别缩进,然后你的代码严重错误。可能是圭多自己?无论如何。如果你有100个级别,你可能会比他们需要的更加努力。
>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.



假设每个序列中有100个等级和2个项目,你将通过内循环以1267650600228229401496703205376迭代结束



假设每次迭代需要一个皮秒,运行程序需要大约40亿美元。


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.



我猜这正是OP提出问题的原因。他只想要

尽快开始;-)


-

问候,

Wojtek Walczak,
http://www.stud.umk .pl / ~wojtekwa /


这篇关于Re:我们可以使用多少嵌套?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆