I have a class, for example:
class Example:
def __init__(self):
self.x = 1
def add(self):
self.x += 1
return self
If I want to chain methods, I can use:
my_example = Example()
my = my_example.add().add().add().add().add().add()
# Use 'my' later on and modify and so on...
Will it consume more and more memory whenever I use add()
or something ?
I want to build a library with method chaining functionality, but just wondering is this good ?