caterinaurban / Typpete

35 stars 6 forks source link

Differentiate between instance methods and callable objects attached as instance variables #21

Closed mostafa-abdullah closed 7 years ago

mostafa-abdullah commented 7 years ago

Currently, any attribute call adds the instance as a first argument for the receiver, accordingly, the following doesn't work.

class A:
    def __init__(self, f):
        self.f = f
    def g(self):
        return self.f()

def f():
    pass

x = A(f)

because the call self.f() in method g is considered a method call, so it as the instance self as an argument, whereas function f doesn't expect any arguments.