Self Referencing Class Definition in python

后端 未结 6 1946
野的像风
野的像风 2020-12-01 11:00

is there any way to reference a class name from within the class declaration? an example follows:

class Plan(SiloBase):
    cost = DataField(int)
    start =         


        
6条回答
  •  执念已碎
    2020-12-01 11:39

    I understand what is happening, the name of the class isn't in scope inside the class.

    Not exactly. The name of the class is not yet defined when defining it's contents (e.g. scope).

提交回复
热议问题