42
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[python] pythonの最大再帰処理回数(Maximum Recursion Depth)を変更する

Last updated at Posted at 2018-07-26

Pythonが許容する 再帰処理の回数 を超えると
プログラムが下記のようなエラーが出て停止するようになります。

RecursionError: maximum recursion depth exceeded

そのような時は、コードを先に見なすべきですが、
一時的にその再帰回数をあげる方法もあります。

import sys
 
sys.setrecursionlimit(2000)

現在の設定値は、 sys.getrecursionlimit() で取得可能です。
デフォルト値は、 1000 です。

42
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
42
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?