what is the chain function in python code example
Example 1: class chain methods python
class foo():
def __init__(self, kind=None):
self.kind = kind
def my_print(self):
print (self.kind)
return self
def line(self):
self.kind = 'line'
return self
def bar(self):
self.kind='bar'
return self
Example 2: class chain methods python
a = foo()
a.line()
a.my_print()
a.bar()
a.my_print()
assert a.kind == 'bar'