How do I call method .get_item(Example1()).do_something() in class Base from inside the class Example2?
class Base:
items = []
def add_item(self, item):
self.items.append(item)
def get_item(self, item):
return self.items[0]
class Item:
pass
class Example1(Item):
def do_something(self):
print('do_something()')
class Example2(Item):
def __init__(self):
'''
How call this method .get_item(Example1()).do_something() ?
'''
if __name__ == '__main__':
base = Base()
base.add_item(Example1())
base.add_item(Example2())
__init__of Example2 or are you trying to call the__init__method itself? Actually I can't understand what you are asking. Please provide more information.