A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

张宗杰

初级黑马

  • 黑马币:

  • 帖子:

  • 精华:

© 张宗杰 初级黑马   /  2018-9-18 19:17  /  1174 人查看  /  9 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

【ID】张宗杰
【你的性别】男
【来自哪里】合肥
【兴趣爱好】运动
【来的目的】学习
【一句心情】舒服呀

9 个回复

倒序浏览
呵呵杰哥
回复 使用道具 举报
杰哥 牛皮
回复 使用道具 举报
呵呵,杰哥
回复 使用道具 举报
[Python] 纯文本查看 复制代码
class MyFun(object):
	def __init__(self, fun):
		self.fun = fun

	def __call__(self, *args, **kwargs):
		print("额外的功能")

		self.fun()

	@classmethod
	def set_value(cls, value):
		print(cls)
		print(value)
		return cls


# 分两步
# MyFun.set_value("oldyang") ,得到类的引用
# @类的引用(@MyFun)

@MyFun.set_value("oldyang")  # test = MyFun(test)
def test():
	print("test")


test()
回复 使用道具 举报
[Python] 纯文本查看 复制代码
class MyFun(object):
	def __init__(self, fun):
		self.fun = fun

	def __call__(self, *args, **kwargs):
		print("额外的功能")

		self.fun()

	@classmethod
	def set_value(cls, value):
		print(cls)
		print(value)
		return cls


# 分两步
# MyFun.set_value("oldyang") ,得到类的引用
# @类的引用(@MyFun)

@MyFun.set_value("oldyang")  # test = MyFun(test)
def test():
	print("test")


test()
回复 使用道具 举报
回复 使用道具 举报
欢迎欢迎
回复 使用道具 举报

欢迎欢迎
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马