Python multimeta with nested classes

  Kiến thức lập trình

I would expext the following example to work, but it does not. Am I missing something obvious or is there a reason why multimeta seemingly does not work with nested classes?

[N.B. As a workaround i am using the @multimethod decorator on individual functions instead]

from __future__ import annotations

from multimethod import multimeta

class Foo(metaclass=multimeta):
 
  class _Bar(metaclass=multimeta):

    def __init__(self, parent: Foo) -> None:
      self._parent = parent

  def __init__(self) -> None:
    self._baz = self._Bar(self)


if __name__ == "__main__":
  foo = Foo()

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT