Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Nothing happens.


devel / comp.lang.python / Re: How to replace an instance method?

SubjectAuthor
o Re: How to replace an instance method?Chris Angelico

1
Re: How to replace an instance method?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: rosuav@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: How to replace an instance method?
Date: Sun, 18 Sep 2022 10:21:07 +1000
Lines: 30
Message-ID: <mailman.457.1663460481.20444.python-list@python.org>
References: <f9f8bac0-9a27-8615-6164-38aa2d9e0fbb@t-online.de>
<CACL+1avBfoS0xDPE1F1CuJDSzDzi_6Ra8FT04c_-Ro1+Uk3OeQ@mail.gmail.com>
<a8db9987-7f35-6b45-1ce9-f17a880dc00a@t-online.de>
<CAPTjJmoPhVkGRqLzCUFDntp2JpR5VX_1qTYJJtj8AnAtDOAWnA@mail.gmail.com>
<CACL+1atihVKMbap8CKEoYuxCsmDnoOAK9N8KY-cn+G5ty2EUHw@mail.gmail.com>
<CAPTjJmrcGWYVr=w9ZMVxxmrU7JT7===5Pe1C2KL5igDK7G8iGw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de ltovcFZBAiFC7KgPr28Pww48sc1UdqLberg0VOQdGCTg==
Return-Path: <rosuav@gmail.com>
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=gmail.com header.i=@gmail.com header.b=dvdKdS1k;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; '2022':
0.05; 'sun,': 0.07; 'thing.': 0.07; 'underlying': 0.07;
'angelico': 0.09; 'fundamental': 0.09; 'though.': 0.09; 'unlike':
0.09; 'accessed': 0.16; 'attributes': 0.16; 'chrisa': 0.16;
'eryk': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'inspecting': 0.16; 'instance': 0.16; 'sept':
0.16; 'whichever': 0.16; 'wrapper': 0.16; 'wrote:': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'basically': 0.22;
'skip:_ 10': 0.22; 'subject:How': 0.23; 'object': 0.26; "isn't":
0.27; 'function': 0.27; 'chris': 0.28; 'fact': 0.28; 'sense':
0.28; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'one.': 0.35; 'yes,': 0.35; 'from:addr:gmail.com': 0.35; 'also,':
0.36; 'functions': 0.36; 'really': 0.37; 'using': 0.37;
'received:209.85': 0.37; 'received:209': 0.39; 'two': 0.39;
'received:209.85.208': 0.39; 'still': 0.40; 'both': 0.40; 'in,':
0.60; 'method': 0.61; 'thus': 0.64; 'back': 0.67; 'choose': 0.67;
'that,': 0.67; 'subject:method': 0.69; 'truly': 0.70; 'attribute':
0.84; 'falls': 0.84; 'type,': 0.84; 'type.': 0.84; 'emphasizes':
0.91; 'locked': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date;
bh=y10A7vBCDiVVCHE0MQgRlYyNtEsOme8SF8ujMTugpg4=;
b=dvdKdS1k/0HnrZyc1zsXomJ5lBJ/YJF8cXawO5MuLyRXvoUvYqSippslhpI4JqaU+U
5Jd4UqdWtiiaAdWtMxeljoSoXzxHvxYylLm8Oz1G+9jRuUqIxICSPn8sTaLlrMyZA6uI
KwGBeWlXi1NtJMksk0AfMqVAj6oOg3nNF60F9822ft5zvF4Qn9cWXOQB3YsjAFf89Agf
SeKs50qLf4EVCvoFa+Cpf9jv2oCEZTbT5fLd2E0XSAexv5h/jBQBaGoLIDxufPKNLqO3
kZjWtriYxvBvY2ZqTiUc9OGAQPnuDCbyy7hPmC72I7TxJCMuh+Qi9BA7vryTxOT9mv1j
MIBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date;
bh=y10A7vBCDiVVCHE0MQgRlYyNtEsOme8SF8ujMTugpg4=;
b=HXSIHUaZdzOvvItP1D15tvN7TGnDEBWtSwxXylhE393AfDXnx/igVEltsJi4b1lPlR
uZZfiv2kgeJ7LbSEDLgZ7vSuWX1Y5dC7xLwqVfEtbAiaEblOdXWXZhTeFsecjRC0jfO2
f2G914VUBb04s7Ym+lQEtdjjDcjJN7Kok47/ry4D/s/5Gi/qMdU/bwuPFYZR+52HHSCY
9AWZ8lb2WDMy7BzCIbB9FrODJsl5Xr5oCDYju7eGkfHcJVjpE11xgVvejVJZYsqtoLV0
Wew/hvEKgLIBPI1JK/778pYh6kQqgLGRuyjEaE5lekhywbSm71MqPTSW1g5fHs3xomIq
d7rQ==
X-Gm-Message-State: ACrzQf054ATHxs4pCEOJjzLo6pGZiHzqEySuvW50DkIyNbFuIsoQUtdr
x1DCXn4IgM8rtFK1awG9IYuiXACBrndq6opl/z+MQmFH
X-Google-Smtp-Source: AMsMyM7RXZuVVud0POp0b4L0yaN21Q7xHSuK/LtIz0H8xs0fVbwLi9tTfhekzLqj3FnATv3uVAPgzQGeVnVvg5CvJB0=
X-Received: by 2002:a05:6402:f07:b0:450:bf95:59e9 with SMTP id
i7-20020a0564020f0700b00450bf9559e9mr9667453eda.46.1663460479201; Sat, 17 Sep
2022 17:21:19 -0700 (PDT)
In-Reply-To: <CACL+1atihVKMbap8CKEoYuxCsmDnoOAK9N8KY-cn+G5ty2EUHw@mail.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: <CAPTjJmrcGWYVr=w9ZMVxxmrU7JT7===5Pe1C2KL5igDK7G8iGw@mail.gmail.com>
X-Mailman-Original-References: <f9f8bac0-9a27-8615-6164-38aa2d9e0fbb@t-online.de>
<CACL+1avBfoS0xDPE1F1CuJDSzDzi_6Ra8FT04c_-Ro1+Uk3OeQ@mail.gmail.com>
<a8db9987-7f35-6b45-1ce9-f17a880dc00a@t-online.de>
<CAPTjJmoPhVkGRqLzCUFDntp2JpR5VX_1qTYJJtj8AnAtDOAWnA@mail.gmail.com>
<CACL+1atihVKMbap8CKEoYuxCsmDnoOAK9N8KY-cn+G5ty2EUHw@mail.gmail.com>
 by: Chris Angelico - Sun, 18 Sep 2022 00:21 UTC

On Sun, 18 Sept 2022 at 09:37, Eryk Sun <eryksun@gmail.com> wrote:
>
> On 9/17/22, Chris Angelico <rosuav@gmail.com> wrote:
> >
> > The two are basically equivalent. Using functools.partial emphasizes
> > the fact that all you're doing is "locking in" the first parameter;
> > using the __get__ method emphasizes the fact that functions are,
> > fundamentally, the same thing as methods. Choose whichever one makes
> > sense to you!
>
> Functions are really not "fundamentally, the same thing as methods".
> They're only the same in that they're both callable. Also, a method's
> __getattribute__() falls back on looking up attributes on the
> underlying function (i.e. the method's __func__), such as inspecting
> the __name__ and __code__. A fundamental difference is that, unlike a
> function, a method is not a descriptor. Thus if a method object is set
> as an attribute of a type, the method does not rebind as a new method
> when accessed as an attribute of an instance of the type.

An unbound method in Python 2 was distinctly different from a
function, but in Python 3, they really truly are the same thing. A
bound method object is a small wrapper around a function which binds
its 'self' parameter; that's a distinction, but not a fundamental one.
Yes, a bound method isn't a descriptor; that's not really a huge
difference either, though.

A method IS a function. A bound method is a function with one argument
locked in, but still a function.

ChrisA


devel / comp.lang.python / Re: How to replace an instance method?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor