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"
If you try to make it a @staticmethod, though, you would need to provide
a class argument to super(), but a staticmethod does not pass one in.
On 11/11/2022 11:21 AM, Ian Pilcher wrote:
Is it possible to access the name of a superclass static method, when
defining a subclass attribute, without specifically naming the super-
class?
Contrived example:
class SuperClass(object):
@staticmethod
def foo():
pass
class SubClass(SuperClass):
bar = SuperClass.foo
^^^^^^^^^^
Is there a way to do this without specifically naming 'SuperClass'?
--
https://mail.python.org/mailman/listinfo/python-list