1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] is there a python pattern that allows an attribute in a base class be an instance of...

Discussão em 'Python' iniciado por Stack, Setembro 14, 2025.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página