Discuss / Python / 你们的做法全都错误

你们的做法全都错误

Topic source

Medivh

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

其实你们的做法全部都是错误的,在让你们做一下这个试题的时候,还没讲 __call__ 方法呢

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

正确的解答方法是:

class Chain(object):    def __init__(self, path=''):        self._path = path    def __getattr__(self, path):        if(path =='users'):            return Chain        return Chain('%s/%s' % (self._path, path))    def __str__(self):        return self._path    __repr__ = __str__

绊倒铁盒

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

你这解决方案完全是“硬编码”,治标不治本啊

B O O M!

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

太死板了,这位兄台。不是老师没教,就不用。在工作中一定不能这样去思考业务哦。自己要去多思考和结合资料。也过了一年了,希望你现在不是这样


  • 1

Reply