def add(x, y):
    return x + y
squared = lambda x: x ** 2
print(getsource(add))
print(getsource(squared))


class Foo(object):

    def bar(self, x):
        return x * x + x
f = Foo()
print(getsource(f.bar))
Can Python print a function definition?