It seems that an acceptable answer to the question
What is a method?
is
A method is a function that's a member of a class.
I disagree with this.
class Foo(object):
pass
def func():
pass
Foo.func = func
f = Foo()
print "fine so far"
try:
f.func()
except TypeError:
print "whoops! func must not be a method after all"
- Is
funca member ofFoo? - Is
funca method ofFoo?
I am well aware that this would work if func had a self argument. That's obvious. I'm interested in if it's a member of foo and in if it's a method as presented.