Best way to do parent child relationship in Python 3 with circular dependencies -
in python 3, have routerdevice class, , interface class in different files. routerdevice has list of interfaces, , interface has reference parent routerdevice.
i understand issue, having, circular dependencies described in stackoverflow.com question
my question is, how fix in sensible way? import inside of __init__
in interface class, need before, take routingdevice 1 of __init__
parameters.
class networkinterface: def __init__(self, parentdevice: routingdevice):
i know having circular dependencies considered bad practice, having parent/child realtionship seems 1 feel exception, figure out how make work in current structure, if @ possible of course.
Comments
Post a Comment