Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

No directory.


devel / comp.lang.python / Re: Superclass static method name from subclass

SubjectAuthor
o Re: Superclass static method name from subclassThomas Passin

1
Re: Superclass static method name from subclass

<mailman.920.1668186176.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20280&group=comp.lang.python#20280

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: lis...@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Superclass static method name from subclass
Date: Fri, 11 Nov 2022 12:02:37 -0500
Lines: 36
Message-ID: <mailman.920.1668186176.20444.python-list@python.org>
References: <ddbbb03e-4c0f-caa4-045f-4e745785ae3f@gmail.com>
<1686043e-1dbb-e284-9f76-f8be1c0e63b4@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de dCFIjzis1lTOVMiEWPrjagQ6K8WztjjNKmDbN1MGbkZw==
Return-Path: <list1@tompassin.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=tompassin.net header.i=@tompassin.net header.b=ljRPQQ/p;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'skip:@ 10': 0.03;
'argument': 0.04; 'def': 0.04; 'subject:name': 0.07; 'example:':
0.09; 'prints': 0.09; 'skip:\xc2 20': 0.09; '@classmethod': 0.16;
'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'static': 0.16; 'wrote:': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'seems': 0.26;
'header:User-Agent:1': 0.30; 'am,': 0.31; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'bar': 0.35; "skip:' 10":
0.37; 'subject:from': 0.37; 'class': 0.37; 'way': 0.38; 'define':
0.40; 'try': 0.40; 'provide': 0.60; 'skip:\xc2 10': 0.62; 'pass':
0.64; 'in.': 0.64; 'header:Received:6': 0.67; 'received:64': 0.67;
'subject:method': 0.69; '8bit%:100': 0.76; 'method,': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1668186158; a=rsa-sha256;
cv=none;
b=OOzX+cQ5zowNHI656aWbD4xCeAmLevUZWWzREpMp01Y+bcl/Ta/8t//MlDh7lJ8tJqeUJP
91Kffa5k5VRq7tg4WY6IMcMbuClhCCol0JBHb6LNWEx/PL8M6AvmfvlWMiPCb5tA7J8eh2
9HfUacUWCUIcd9OJsEAYI2TJLxjE+GQmue12KxafAj5ge0MLNomBzusqP0x7u8wQv49f2H
eOe66+nw2x8/8+l7mXX6WBiWrZy1S1kxdDZNIBLZTW7uIQCI4Jdi2pJUeuz6TxZQFC9KLG
8VeXdZk6EIrgXW4om0W+fVE2V5sTm6zQpYrjwsUL62Vv8BcC64tDJPtg2aVQSg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1668186158;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=J0BAs25p9vZIaYb2MrcLr6KqMdo+bJbCz3NsA+xZVfY=;
b=NTNb843jO8rx//AQ/cNCz/vnJ9D2vizJITMUynfBwa4klz0d5UuVYnM51mW6lmkUMS/JQj
wwRwR+WGBhKPf5vAxG5aC4mtDW2YJnsaUV1Y3cs4vPYbzgzff8kvSCLzjNZMQ16ZCiyFWX
7XfeOkPDZBhwd6SOOZQjvp/DJpOX/IASU+TNZjxRqnmIr4ZUe+C4YDRgVB0wf3WNJlwGkL
xrtVKT6NmSh53lWq5QgVdSFLdhLyWt2o9R/kJbola0V5o9R8puyU1aREPOAELmZyzkuK0L
5gkcgerwT1732iC1mLNSNMEtxZ02++oBJMcuy1rK53nktdmHCea/qfz092fe6g==
ARC-Authentication-Results: i=1; rspamd-5cb65d95c4-wdxgp;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Slimy-Battle: 3f1995b00122fff0_1668186158968_545290766
X-MC-Loop-Signature: 1668186158968:3205315103
X-MC-Ingress-Time: 1668186158968
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1668186158;
bh=J0BAs25p9vZIaYb2MrcLr6KqMdo+bJbCz3NsA+xZVfY=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=ljRPQQ/p1r/e/94Dod9ieFoWwfktVlcCgdA8wwyD4RvYAiHga172TZhtnEvqBPQMX
CDck8T2AEpMiA92XoFdlWmJlFIVTishtjXHYZWzPknQKvdpwa8OSRfEsKva9+i0m1C
W6mgqUCMz8+gNP+Nry+e6vEfCEMOYvY64iVtmF7cBNZW74BSPeI4ez1UEjWReRm5zV
qpbLjLTSyBgveq/ZSpQzYYA86heNQC+Iq0yQqX4evJkqtkYVMCO4uTWZJbhreColeO
wWO7FM5U0n7wsH0JxY6Vl/89HdOLiw0ieqIvA9PqwhXHF8+SuS7ASYahwCqXQzhNg+
l0UpVUUDNV1wQ==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Content-Language: en-US
In-Reply-To: <ddbbb03e-4c0f-caa4-045f-4e745785ae3f@gmail.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <1686043e-1dbb-e284-9f76-f8be1c0e63b4@tompassin.net>
X-Mailman-Original-References: <ddbbb03e-4c0f-caa4-045f-4e745785ae3f@gmail.com>
 by: Thomas Passin - Fri, 11 Nov 2022 17:02 UTC

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'?
>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor