Discuss / Python / 输出"github.com/michael/michael/branches"

输出"github.com/michael/michael/branches"

Topic source

zhr305

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

classChain(object):

    def __init__(self, path=''):

        self.__path = path

    def __getattr__(self, t):

        if t == 'users':

            return lambda name: Chain('%s/%s' %(self.__path, name))

        return Chain('%s/%s' % (self.__path,t))

    def __str__(self):

        return self.__path

    __repr__ = __str__

print('github.com',Chain().users('michael').users('michael').branches, sep='')


  • 1

Reply