RecursionError: maximum recursion depth exceeded in comparison ? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: RecursionError: maximum recursion depth exceeded in comparison ? (/thread-16790.html) Pages:
1
2
|
RE: RecursionError: maximum recursion depth exceeded in comparison ? - micseydel - Mar-15-2019 I should probably not have assumed that you are familiar with mutability in Python. Basically, when you use a list in a default argument, it's always the same list, which can be edited (as opposed to a tuple). Because it's always the same list, edits to that "leak" in the sense that changes you might not have expected will worm into things. RE: RecursionError: maximum recursion depth exceeded in comparison ? - leoahum - Mar-18-2019 (Mar-15-2019, 08:39 PM)ichabod801 Wrote: Again, you are not being clear. We need the full text of the error you are getting. Here is the full error text message. Traceback (most recent call last): File "C:/Users/hali/Downloads/11.py", line 126, in <module> L.append(MoveAcorHeight(Lx[i], Ly[i], xgap, ygap, H[i])) File "C:/Users/hali/Downloads/11.py", line 31, in MoveAcorHeight return MoveAcorHeight(lx, ly, xgap, ygap, H, itn, K, itn2) File "C:/Users/hali/Downloads/11.py", line 103, in MoveAcorHeight return MoveAcorHeight(lx, ly, xgap, ygap, H, itn, K, itn2) File "C:/Users/hali/Downloads/11.py", line 40, in MoveAcorHeight PrebsX[K[i][0]].append(lx[i]) IndexError: list index out of range (Mar-15-2019, 10:56 PM)micseydel Wrote: I'm taking a guess at your issue... Default function parameters are only evaluated once, at function definition. Take this example: Thanks! Problem solved. It was a genius guess! BTW,I did try to reproduce my code in a shorter version when I started this thread, but that version failed to reflect the facts. Then I failed to reproduce another version. |