Discuss / Python / 交作业

交作业

Topic source

刚开始没用__call()__函数,虽然调试成功了,但是完全失去了 延展性。

	def __init__(self, path=''):
		self._path = path

	def __getattr__(self, path):
		#print (self._path, path)
		return Chain('%s/%s' % (self._path, path))

	def __call__(self,name):
		return Chain('%s/%s' % (self._path, name))

	def __str__(self):
		return 'GET'+' '+self._path
	__repr__ = __str__

  • 1

Reply