Superclass static method name from subclass

Ian Pilcher arequipeno at gmail.com
Fri Nov 11 17:07:08 EST 2022


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!

-- 
========================================================================
Google                                      Where SkyNet meets Idiocracy
========================================================================



More information about the Python-list mailing list