Discuss / Python / /users/:michael/repos

/users/:michael/repos

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('/users%s/:%s' % (self._path,x) ) 
        return Chain('%s/%s' % (self._path, path))

    def __str__(self):
        return self._path

    __repr__ = __str__


print( Chain().status.user.timeline.list )

print( Chain().users('michael').repos )

  • 1

Reply