# -*- coding:utf-8 -*-classAnt:def__init__(self,x,y):
self.x = x
self.y = y
defanta(self,x,y):
self.x += x
self.y += y
print"%s,%s,%s"%(self,self.x,self.y)
@staticmethoddefstatic_foo(x):# 静态方法print"%s"% x
@classmethoddefclass_foo(cls,x):#类方法print"%s,%s"%(cls,x)
a=Ant(1,2)
a.anta(2,3)# Ant.anta(2,3)'''TypeError:unbound method anta() must be called with Ant instance as first argument (got int instance instead)'''
a.class_foo(1)
Ant.class_foo(1)
a.static_foo(1)
Ant.static_foo(1)'''
类方法和静态方法都可以被类和类实例调用,类实例方法仅可以被类实例调用
类方法的隐含调用参数是类,而类实例方法的隐含调用参数是类的实例,静态方法没有隐含调用参数
'''