Demo entry 6347793

baz

   

Submitted by baz on Feb 16, 2017 at 20:13
Language: Python 3. Code size: 651 Bytes.

class A:
    def __init__(self):
        self.childs = []
        self.addchild()

    def addchild(self):
        self.childs.append(B())
    def foo(self, v):
        self.elem = v + 1
        
class C:
    def __init__(self):
        self.childs = []
        self.addchild()
        
    def addchild(self):
        self.childs.append(B())

class B:
    def __init__(self):
        self.elem = 0
    
    def foo(self):
        self.elem = self.elem + 1
        print('adress_parent????')

a = A()
c = C()

a.childs[0].foo()
c.childs[0].foo()
c.childs[0].foo()
a.childs[0].foo()
c.childs[0].foo()
a.childs[0].foo()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).