On Mon, 4 Jul 2016 09:59 am, eryk sun wrote:

> On Sun, Jul 3, 2016 at 3:32 PM, Steven D'Aprano <st...@pearwood.info>
> wrote:
>>
>> But if you prepare the method ahead of time, it works:
>>
>> from types import MethodType
>> instance.method = MethodType(method, instance)
> 
> That's a fine way to bind a method, but in the context of this
> "descriptor land" topic, I think it's more insightful to call the
> function's __get__ method:


Sure, so long as you remember that in real code you shouldn't be calling
dunder methods directly. I don't know whether Python does any pre- or
post-processing of a descriptor's __get__ method, but it could (if not now,
but in the future).



-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to