Hi
I wrote a python function self_contained(x) that finds all lists in x that
contain themselves.
Here's the body of the function:
def self_contained(x):
L = []
if not isinstance(x, list):
return []
for i in x:
if isinstance(i, list):
if i in i:
L += [i]
return L
L5 =[]
L6 = []
L5.append(L6)
L6.append(L5)
then I compare L5 and L6 in shell:
L5 == L6
and it gives me this error:
RuntimeError: maximum recursion depth exceeded in cmp
I think probably I need to add another parameter to self_contained or to a
helper function to make my function work when I call L5 or L6. So How can I
fix this error??
I put this code: sys.setrecursionlimit(2500) in the begining doens't fix the
error.
And I don't know how to change self_contained to a recursive function can
any1 help me with this?Thanks!
--
View this message in context:
http://python.6.n6.nabble.com/RuntimeError-maximum-recursion-depth-exceeded-in-cmp-tp4471100p4471100.html
Sent from the Python - python-bugs-list mailing list archive at Nabble.com.
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com