yes,

just use SubClass.foo

at least this works for me:

class SuperClass:
   @staticmethod
   def test():
           print("yay")

class SubClass(SuperClass):

   def __init__(self):
           super().__init__()
           SubClass.test()

subclass = SubClass()

Output:

python3.11 test.py
yay


Cheers

Lars


Lars Liedtke
Software Entwickler

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail]        l...@solute.de<mailto:l...@solute.de>


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]


Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de <http://www.solute.de/>
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php




Am 11.11.22 um 17:21 schrieb Ian Pilcher:
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

Reply via email to