Discuss / Python / 链式调用没看懂,老师能讲解一下吗

链式调用没看懂,老师能讲解一下吗

Topic source

Waslay__

#1 Created at ... [Delete] [Delete and Lock User]

class Chain(object):

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

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

def __str__(self):
    return self._path

__repr__ = __str__

  • 1

Reply