I got 2 instances interact with each other, describe in class like
class Fraction:
def __init__(self, top, bottom):
self.num = top
self.den = bottom
def add(self, B: Fraction):
# do add two fractions
This causes NameError: name 'Fraction' is not defined
in line def add(self, B: Fraction):
. I want to catch their type before passing to function like def add(self, B: int):
in Python 3.7 or newer
I know that just ignore the type of B or catch type error inside function but is there a better way to do this?