Superclass static method name from subclass
Thomas Passin
list1 at tompassin.net
Fri Nov 11 19:07:03 EST 2022
On 11/11/2022 5:07 PM, Ian Pilcher wrote:
> On 11/11/22 11:02, Thomas Passin wrote:
>> You can define a classmethod in SubClass that seems to do the job:
>>
>> class SuperClass(object):
>> @staticmethod
>> def spam(): # "spam" and "eggs" are a Python tradition
>> print('spam from SuperClass')
>>
>> class SubClass(SuperClass):
>> @classmethod
>> def eggs(self):
>> super().spam()
>>
>> SubClass.eggs() # Prints "spam from SuperClass"
>
>
> That did it! Thanks!
Glad I could help. I probably should have written
def eggs(clas): # instead of "self"
but it's not actually used anyway.
More information about the Python-list
mailing list