fastai / fastcore

Python supercharged for the fastai library

Home Page:http://fastcore.fast.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cant directly use `@patch_to` to redefine a class constructor

diego898 opened this issue · comments

class A():
    def __init__(self):
        super().__init__()
        print('hi')

A()

@patch_to(A)
def __init__(self):
    super().__init__()
    print('hello')

A()

returns RuntimeError: super(): __class__ cell not found.

Is it worth adding to the docs that this is the case?

commented
class A():
    def __init__(self):
        super().__init__()
        print('hi')

A()

@patch_to(A)
def __init__(self):
    super(A, self).__init__()
    print('hello')

A()