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
  • 33,740
  • 12
  • 54
  • 68
klapeyron
  • 472
  • 6
  • 17

0 Answers0