Is there some clever way to do this that works?
class NamedElement:
def __init__(self, **kwargs):
self.name = Property(name=kwargs.get('name')) #you're going to regret this
class Property(NamedElement):
def __init__(self, **kwargs):
super().__init__(**kwargs)
myprop = Property(name='myprop') #don't hit enter!!!
If anyone wants context, I'm interested in trying to build a UML model in Python .. UML models itself with UML so here I am.
NameElementthat has aProperty-valued attribute.self.name = kwargs.get('name')would avoid the recursion. past that, no idea what you are trying to do. this is one of the cases where articulating your expected result might be more informative than your code. what do you intend your API/data structures to look like?Propertyinstances and passing them as arguments toNameElement.)NameElementandPropertyshould both be subclasses of some other parent, with aPropertynot being a kind ofNamedElement, but both classes being examples of some other (abstract) entity.mypropis aNamedElementwhich has an attributenamewhich is aNamedElementwhich has an attributenamewhich is aNamedElementwhich ...