このBlogは移転しました。今後は aish.dev を御覧ください。

あなたの知らないPythonのひみつ

Pythonでは、ループ・try・withブロックは最大20までしかネストできない。

>>> def spam():
...   while 1:
...     while 2:
...       while 3:
...         while 4:
...           while 5:
...             while 6:
...               while 7:
...                 while 8:
...                   while 9:
...                     while 10:
...                       while 11:
...                         while 12:
...                           while 13:
...                             while 14:
...                               while 15:
...                                 while 16:
...                                   while 17:
...                                     while 18:
...                                       while 19:
...                                         while 20:
...                                           while 21:
...                                             print "Deep!"
...
SystemError: too many statically nested blocks