I have a Python3 class that supports method chaining.
For example, I have methods a()
, b()
and c()
. How can I allow c()
to only be chained after a()
or in another thought, how can I allow b()
not to be chained next with function c()
?
? a().b().c()
? b().c()
? a().c() #only allow this sequence
Is this possible?
Edit:
To define method chaining is self-explanatory in programming. It is basically calling methods in a chain.
method_a().method_b().method_c()
Class Structure
class Test:
def a(self):
...
return self
def b(self):
...
return self
def c(self):
...
return self
question from:
https://stackoverflow.com/questions/65830337/allow-chained-method-calls-in-certain-orders-only 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…