I have a class definition which defines a static method. I have a field which I would like to initialize with the static method. My default thinking led me to this:
class SomeConcreteClass(object):
some_data = SomeConcreteClass.create_default_data()
@staticmethod
def create_default_data():
return 'Foo'
The problem is that when I run this, I get a NameError: name 'SomeConcreteClass' is not defined. It makes sense as the SomeConcreteClass is just being built. Does this mean I cannot use static init functions? Is there an alternate way which is recommended to handle such a situation?
@propertyinstead of it being a field which is initialized at class def time. Really, I am looking on style guidance here.SomeConcreteClass.some_data = SomeConcreteClass.create_default_data()??