On 12Nov2022 09:17, Cameron Simpson <c...@cskk.id.au> wrote:
On 11Nov2022 10:21, Ian Pilcher <arequip...@gmail.com> wrote:
class SubClass(SuperClass):
bar = SuperClass.foo
^^^^^^^^^^
Is there a way to do this without specifically naming 'SuperClass'?
I think not.
Then I saw your "Dealing with non-callable classmethod objects" post
which mentions `__init_subclass__`. Which feels like I've read about
that before, but had entirely slipped my mind.
Maybe:
class SubClass(SuperClass):
@classmethod
def __init__subclass__(cls):
cls.bar = super().foo
would do the trick. Looks clean, but I haven't tried it yet.
Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list