0

I can't figure out why super().method() cannot be called from local scopes:

Correct code:

class A:
    def method(self):
        print('hello')

class B(A):
    def method(self):
        super().method()

B().method()

Error:

class A:
    def method(self):
        print('hello')

class B(A):
    def method(self):
        def f():
            super().method()
        f()

B().method()

Error output:

Traceback (most recent call last):
  File "D:\sample.py", line 12, in <module>
    B().method()
  File "D:\sample.py", line 10, in method
    f()
  File "D:\sample.py", line 9, in f
    super().method()
RuntimeError: super(): no arguments
quamrana
  • 37,849
  • 12
  • 53
  • 71
klapeyron
  • 502
  • 7
  • 18

0 Answers0