Aug-04-2020, 02:37 AM
(This post was last modified: Aug-04-2020, 10:53 AM by deanhystad.)
First lets do the format problem. You need to use curly brackets instead of parenthesis in your format string. This is an easy mistake to make when copying code. Depending on the font, {} can look a lot like ().
print("{0} + {1} = {2}".format('a', 'b', 'c'))Your operator overloading code doesn't work because you use
Self
instead of self
in method __add___. When I ran your code Python told me exactly what and where the error was.Output:Traceback (most recent call last):
File "C:\Users\djhys\Documents\python\musings\junk.py", line 21, in <module>
print("{0} + {1} = {2}"
File "C:\Users\djhys\Documents\python\musings\junk.py", line 12, in __str__
for Item in Self.Input:
NameError: name 'Self' is not defined