I have a class that contains an __init__
method, a method which changes the init value and a __repr__
function that wants to print out the adjusted value
The draft of the code is as follows
class Workflow:
def __init__(self, a):
self.a = a
def build(self):
self.a += 1
def __repr__(self):
value = self.build()
return value
# Driver Code
t = Workflow(1234)
print(t)
And I got an error as follows
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[71], line 3
1 # Driver Code
2 t = Workflow(1234)
----> 3 print(t)
TypeError: __str__ returned non-string (type NoneType)
What's the mistake that I have made? In this case, if I want to print out the value that has beed changed by a method, how should I do that?