Refer to the class variable in another class variable definition

class SomeClass: SOME_CONST = "hello" SOME_OTHER_CONST = SomeClass.SOME_CONST + " world" 

This does not work.

NameError: the name "SomeClass" is not defined

Is there a way to refer to a class inside a class?

+6
source share
1 answer

You do not need a class name

 class SomeClass: SOME_CONST = "hello" SOME_OTHER_CONST = SOME_CONST + " world" 
+12
source

Source: https://habr.com/ru/post/912563/


All Articles