Discuss / Python / 交作业:

交作业:

Topic source
class Chain(object):    def __init__(self, path=''):        self.path = path    def __getattr__(self, item):        return Chain('%s/%s' % (self.path, item))    def __call__(self, *args, **kwargs):        if len(args) == 1:            return Chain('%s/%s' % (self.path, args[0]))    def __str__(self):        return self.path    __repr__ = __str__

  • 1

Reply