inheritance problem

Den Ivanov dsdiv at vladnet.ru
Thu Feb 19 04:00:49 CET 2004


Example:
------------
class c1:
  def method1(self):
    print 'class c1, method1'
  def method2(self):
    print 'class c1, method2'
    self.method1()

class c2(c1):
  def method1(self):
    print 'class c2, method1'
    c1.method2(self)
  def method2(self):
    print 'class c2, method2'

c = c2()
c.method1()
------------
i expect :
class c2, method1
class c1, method2
class c1, method1

but i get this:
class c2, method1
class c1, method2
class c2, method1
class c1, method2
...
RuntimeError: maximum recursion depth exceeded

How fix this?

PS. python 2.1.3




More information about the Python-list mailing list