Discuss / Python / 作业

作业

Topic source

苏生不语_

#1 Created at ... [Delete] [Delete and Lock User]
class Chain(object):

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

    def __getattr__(self, path):
        if path == 'users':
            return lambda x: Chain('/%s/:%s' % (path, x))
        return Chain('%s/%s' % (self._path, path))

    def __str__(self):
        return self._path

  • 1

Reply