Let's say I have a class
class SimpleGenerator(object):
@classmethod
def get_description(cls):
return cls.name
class AdvancedGenerator(SimpleGenerator):
@classmethod
def get_description(cls):
desc = SimpleGenerator.get_description() # this fails
return desc + ' Advanced(tm) ' + cls.adv_feature
Now I have extended each of the above classes to have a concrete one of each:
class StringGenerator(SimpleGenerator)
name = 'Generates strings'
def do_something():
pass
class SpaceShuttleGenerator(AdvancedGenerator)
name = 'Generates space shuttles'
adv_feature = ' - builds complicated components'
def do_something():
pass
Now let's say I call
SpaceShuttleGenerator.get_description()
The issue is that in AdvancedGenerator
I want to call the method in SimpleGenerator
passing along an instance of the class, specifically SpaceShuttleGenerator
. Can this be done?
NOTE: The example is simplified, as my concrete example is more involved. Let's say that my goal is not to concatenate strings.