class testClass(object):
def test1(self):
print "1"
def test1(self):
print "2"
def test1(self):
print "3"
This is a Class containing three methods which all have the same name (and even same signature)
When I call this:
tc = testClass()
tc.test1()
it's not throwing any error, but simplt printing 3.
One more example:
class testClass(object):
def test1(self, a, b):
print "1"
def test1(self, a):
print "2"
def test1(self, a, b, c):
print "3"
Again if I call tc.test1(), it raises an exception:
TypeError: test1() takes exactly 4 arguments (1 given)
So can I assume that in these situations it will always execute the last method defined in the class?
PS: I tried the same with individual functions in a file and got the same result, it executed the last function.