What does cls() function do inside a class method?

前端 未结 3 1800
一生所求
一生所求 2021-02-01 22:26

Today I\'m viewing another\'s code, and saw this:

class A(B): 
    # Omitted bulk of irrelevant code in the class

    def __init__(self, uid=None):
        self         


        
3条回答
  •  粉色の甜心
    2021-02-01 23:12

    It's a class factory.

    Essentially it the same as calling:

    o = A(uid)
    

    cls in def get(...): is A.

提交回复
热议问题