【发布时间】:2013-12-05 08:35:35
【问题描述】:
我是 python 新手。但我知道方法重载。但我对python中的重载感到困惑。这是我的混淆代码,
class OverLoad(object):
"""docstring for OverLoad"""
def __init__(self, arg):
super(OverLoad, self).__init__()
self.arg = arg
def adder(a, b):
print a,b
def adder(*a):
print a
def adder(a):
print a
def adder():
print "no arg"
请解释一下上面的代码。
【问题讨论】:
-
Python 没有方法重载 - 您定义的最后一个方法是使用的方法......这可能是为什么? :) 也许看看:stackoverflow.com/questions/6434482/python-function-overloading
-
谢谢@Jon。你提供的链接对我很有帮助。
标签: python python-2.7 overloading