Let's say I have two files, each with a class in it. int.py
, which has a custom implementation of an integer class, and float.py
, which has a custom implementation of a float class.
I want each class to have a conversion method to the other. For example:
class Integer:
def __init__(self, value):
self.value = value
def to_f():
return Float(self.value)
and
class Float:
def __init__(self, value):
self.value = value
def to_i():
return Integer(self.value)
How can I import the files into each other so that the constructors are available, without causing a circular dependency?