Sometimes, i need to change existing method behaviour or inject meta data for testing purpouses. Like: we have 2 predefined classes which we can't change (we can implement SomeClass* just to ease injecting metadata).
class A(SomeClass1):
def __init__(self):
last_id = self.id
class B(SomeClass2):
def __init__(self):
last_id = self.id
So what should be done to next line print incremented id's (like: 1 2 3) ?
print A().id, B().id, A().id
Aucun commentaire:
Enregistrer un commentaire