Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Beam me up, Scotty!


devel / comp.lang.python / Re: Fallback for operator and other dunder methods

SubjectAuthor
* Re: Fallback for operator and other dunder methodsDom Grigonis
`* Re: Fallback for operator and other dunder methodsEdmondo Giovannozzi
 `- Re: Fallback for operator and other dunder methodsDom Grigonis

1
Re: Fallback for operator and other dunder methods

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: dom.grigonis@gmail.com (Dom Grigonis)
Newsgroups: comp.lang.python
Subject: Re: Fallback for operator and other dunder methods
Date: Wed, 26 Jul 2023 21:35:25 +0300
Lines: 30
Message-ID: <mailman.199.1690396529.23016.python-list@python.org>
References: <2D6F0153-5FAE-49A1-A5B0-23CF9AAED4E7@gmail.com>
<CAPTjJmoRd8psQmC+urJAE5QRM8st3_ihv3v8ODQNjRLEiPHfRA@mail.gmail.com>
<333FA876-8F7B-42D1-BD5C-6AEB07EE03BB@gmail.com>
<CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com>
<9EB0B006-9309-42EE-8D60-A6EF12B0B1BF@gmail.com>
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\))
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de p9wAKIxg13Bq0yJUbxlfbAZ/8REVX7Zw1yMinNYbjo0Q==
Cancel-Lock: sha1:DfhU9yu6VRNLfFJ/Uyt4GyJ6Q7s= sha256:abqWr+C1K+3gXWRDPvcBL4OR19U25s6WNUve+GE5wwM=
Return-Path: <dom.grigonis@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=iDpSPXtb;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.049
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'jul': 0.04; '2023': 0.07;
'angelico': 0.09; 'cc:addr:python-list': 0.09;
'didn\xe2\x80\x99t': 0.09; 'cc:no real name:2**0': 0.14;
'url:mailman': 0.15; 'chrisa': 0.16; 'easiest': 0.16;
'received:apple': 0.16; 'received:smtpclient.apple': 0.16;
'wrote:': 0.16; 'message-id:@gmail.com': 0.18;
'cc:addr:python.org': 0.20; 'skip:_ 10': 0.22; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25;
'tried': 0.26; 'chris': 0.28; 'url-ip:188/8': 0.31; 'checks':
0.32; 'python-list': 0.32; 'subject:for': 0.33; 'there': 0.33;
'work.': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'those':
0.36; "it's": 0.37; 'class': 0.37; 'could': 0.38; 'use': 0.39;
'neither': 0.39; 'wed,': 0.39; 'something': 0.40; 'me.': 0.62;
'simply': 0.63; 'look': 0.65; 'exactly': 0.68; 'order': 0.69;
'received:mail-lj1-x22d.google.com': 0.69; 'slots': 0.69;
'subject:other': 0.69; "you'll": 0.73; 'attribute': 0.84; 'catch':
0.84; 'dom': 0.84; 'received:88': 0.84; 'want.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1690396528; x=1691001328;
h=to:references:message-id:content-transfer-encoding:cc:date
:in-reply-to:from:subject:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=k7lAB+flCsw51RuL4+xrR03LfU/xkUFRGcIzw8nCZSI=;
b=iDpSPXtbLoeR92se1DIwTN4uvJHEmNkxvIPCQZiEf086uoEeA2z9kSsIrZHTpTrs7W
/wXYDdynhJfK+2xO5Y4p2QCgcyQL9+AuTVecw/FB+7IbhYOyxgUjqW3m4nbs4Pn6P0lb
47yZJQnkhXSEvWFTBg02iOOGNlJvqubZTFuxzPNHUL+MHPMFB2cZe4ZCHZx0FwIVJgvY
vJdx5PzQY5iPGXgtz2fcnAd1b8hRkRa/PLRIhx7KY1mLVgHew9Pq4I032JvCvRlsn6cM
LP9D/dqyq6/eAHdnSRLnC2Pz/x+1VKgHSOiFUjkC9C7Q7XA4YBtJdz5zhcaAQJch227+
tdcw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1690396528; x=1691001328;
h=to:references:message-id:content-transfer-encoding:cc:date
:in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=k7lAB+flCsw51RuL4+xrR03LfU/xkUFRGcIzw8nCZSI=;
b=NPDSkUoSxOydYTZBzoig0s89MlW3E7IgTNLo3ySlcHkdLXttJTF64t+l8wfnFvC4Nn
mHktAIJLvh+nlb9tlGNPK9ayk4Y1LHZR5mlqUQpcR49c/n9ZeOBSeUeqU32inSp3sk0r
8FCfnlGyQZqEh7f624TpBIzoFhp2YVAO5KXNOnoL9eg8YAuj4M9fsf+DKl7Ez5ZjRa12
5eXpn9WAuEA7tvXQP56uCw1UBi0kjJW7lBqZRhcxlVOW8Qeriul2CDLuluOY+OiLGq4T
xO8oF+wuu4+olIv17tiqIF/Z74ynE+efH7yBIf3AQcmyPwfRpAnGTyWRFZWEkfj4HsHe
GdVQ==
X-Gm-Message-State: ABy/qLZCC7wQNOdI2ga5ApmmjqnMbEYr/FBZj803i50GG6YaN8EhByf4
OCZDfK14g+M95wrlu5IJttk=
X-Google-Smtp-Source: APBJJlEXKUt8nhSBbSKmDuNhKkQ5+7zbgrYQ33xdco1bKX3E22xIw6hHhJJOEqGiQJsqX7R1MPnryQ==
X-Received: by 2002:a2e:9cd4:0:b0:2b6:efd0:5dd8 with SMTP id
g20-20020a2e9cd4000000b002b6efd05dd8mr2002741ljj.46.1690396527309;
Wed, 26 Jul 2023 11:35:27 -0700 (PDT)
In-Reply-To: <CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com>
X-Mailer: Apple Mail (2.3654.120.0.1.15)
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: <9EB0B006-9309-42EE-8D60-A6EF12B0B1BF@gmail.com>
X-Mailman-Original-References: <2D6F0153-5FAE-49A1-A5B0-23CF9AAED4E7@gmail.com>
<CAPTjJmoRd8psQmC+urJAE5QRM8st3_ihv3v8ODQNjRLEiPHfRA@mail.gmail.com>
<333FA876-8F7B-42D1-BD5C-6AEB07EE03BB@gmail.com>
<CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com>
 by: Dom Grigonis - Wed, 26 Jul 2023 18:35 UTC

Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__ of meta is being invoked.

> On 26 Jul 2023, at 10:01, Chris Angelico via Python-list <python-list@python.org> wrote:
>
> On Wed, 26 Jul 2023 at 16:52, Dom Grigonis <dom.grigonis@gmail.com> wrote:
>>
>> Could you give an example? Something isn’t working for me.
>>
>
> This is a metaclass:
>
> class Meta(type):
> ...
> class Demo(metaclass=Meta):
> ...
>
> In order to catch those kinds of attribute lookups, you'll need the
> metaclass to hook them. And you might need to use __getattribute__
> rather than __getattr__. However, there may also be some checks that
> simply look for the presence of the attribute (see: slots), so you may
> find that it's even more complicated. It's usually easiest to just
> create the slots you want.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list

Re: Fallback for operator and other dunder methods

<acbcc12f-e2e3-4d59-8623-3beb6dabe93fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a05:620a:490:b0:76c:d4b7:5dba with SMTP id 16-20020a05620a049000b0076cd4b75dbamr14909qkr.15.1690995299857;
Wed, 02 Aug 2023 09:54:59 -0700 (PDT)
X-Received: by 2002:a05:6808:2117:b0:3a7:56ad:cb98 with SMTP id
r23-20020a056808211700b003a756adcb98mr2726211oiw.9.1690995299577; Wed, 02 Aug
2023 09:54:59 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Wed, 2 Aug 2023 09:54:59 -0700 (PDT)
In-Reply-To: <mailman.199.1690396529.23016.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=192.107.52.25; posting-account=2VbiMAoAAADZ_2MR3YxvYmpYWYw9FTXX
NNTP-Posting-Host: 192.107.52.25
References: <2D6F0153-5FAE-49A1-A5B0-23CF9AAED4E7@gmail.com>
<CAPTjJmoRd8psQmC+urJAE5QRM8st3_ihv3v8ODQNjRLEiPHfRA@mail.gmail.com>
<333FA876-8F7B-42D1-BD5C-6AEB07EE03BB@gmail.com> <9EB0B006-9309-42EE-8D60-A6EF12B0B1BF@gmail.com>
<CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com> <mailman.199.1690396529.23016.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <acbcc12f-e2e3-4d59-8623-3beb6dabe93fn@googlegroups.com>
Subject: Re: Fallback for operator and other dunder methods
From: edmondo.giovannozzi@gmail.com (Edmondo Giovannozzi)
Injection-Date: Wed, 02 Aug 2023 16:54:59 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2739
 by: Edmondo Giovannozzi - Wed, 2 Aug 2023 16:54 UTC

Il giorno mercoledì 26 luglio 2023 alle 20:35:53 UTC+2 Dom Grigonis ha scritto:
> Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__ of meta is being invoked.
> > On 26 Jul 2023, at 10:01, Chris Angelico via Python-list <pytho...@python.org> wrote:
> >
> > On Wed, 26 Jul 2023 at 16:52, Dom Grigonis <dom.gr...@gmail.com> wrote:
> >>
> >> Could you give an example? Something isn’t working for me.
> >>
> >
> > This is a metaclass:
> >
> > class Meta(type):
> > ...
> > class Demo(metaclass=Meta):
> > ...
> >
> > In order to catch those kinds of attribute lookups, you'll need the
> > metaclass to hook them. And you might need to use __getattribute__
> > rather than __getattr__. However, there may also be some checks that
> > simply look for the presence of the attribute (see: slots), so you may
> > find that it's even more complicated. It's usually easiest to just
> > create the slots you want.
> >
> > ChrisA
> > --
> > https://mail.python.org/mailman/listinfo/python-list

For numpy arrays you can find some suggestion at:
https://numpy.org/doc/stable/user/basics.dispatch.html

Re: Fallback for operator and other dunder methods

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: dom.grigonis@gmail.com (Dom Grigonis)
Newsgroups: comp.lang.python
Subject: Re: Fallback for operator and other dunder methods
Date: Fri, 4 Aug 2023 19:07:50 +0300
Lines: 55
Message-ID: <mailman.205.1691165275.23016.python-list@python.org>
References: <2D6F0153-5FAE-49A1-A5B0-23CF9AAED4E7@gmail.com>
<CAPTjJmoRd8psQmC+urJAE5QRM8st3_ihv3v8ODQNjRLEiPHfRA@mail.gmail.com>
<333FA876-8F7B-42D1-BD5C-6AEB07EE03BB@gmail.com>
<9EB0B006-9309-42EE-8D60-A6EF12B0B1BF@gmail.com>
<CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com>
<mailman.199.1690396529.23016.python-list@python.org>
<acbcc12f-e2e3-4d59-8623-3beb6dabe93fn@googlegroups.com>
<3DDEF864-9301-438A-9895-04D8D4A2A614@gmail.com>
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\))
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de zBxW7ujZsDAIPdx4Cwwu1wNwhjC4uK8VnbIFVS2dvNqA==
Cancel-Lock: sha1:AwJJ94ivV8I/f8eU4M5K2SiSnTE= sha256:iZaTKGyvC8Kn85otcLX2qFtR48yDnvFiANbqDl6OotY=
Return-Path: <dom.grigonis@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=Advb6Exa;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.022
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'jul': 0.04; '2023': 0.07;
'arrays': 0.07; 'aug': 0.07; 'class="">': 0.07; 'suggestion':
0.07; '!important;"': 0.09; 'angelico': 0.09; 'cases.': 0.09;
'cc:addr:python-list': 0.09; 'didn\xe2\x80\x99t': 0.09; 'numpy':
0.09; 'url-ip:151.101.0.223/32': 0.09; 'url-
ip:151.101.128.223/32': 0.09; 'url-ip:151.101.192.223/32': 0.09;
'url-ip:151.101.64.223/32': 0.09; 'url:stable': 0.09; 'cc:no real
name:2**0': 0.14; 'url:mailman': 0.15; '>>>>': 0.16; 'chrisa':
0.16; 'easiest': 0.16; 'received:apple': 0.16;
'received:smtpclient.apple': 0.16; 'url:basics': 0.16; 'url:doc':
0.16; 'url:numpy': 0.16; 'wrote:<span': 0.16; 'wrote:': 0.16;
'message-id:@gmail.com': 0.18; 'helvetica;': 0.19;
'cc:addr:python.org': 0.20; 'issue': 0.21; 'maybe': 0.22; 'skip:_
10': 0.22; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0': 0.25;
'url-ip:188.166/16': 0.25; 'seems': 0.26; 'tried': 0.26; '>>>':
0.28; 'chris': 0.28; 'email addr:python.org&gt;': 0.28; 'url-
ip:188/8': 0.31; 'checks': 0.32; 'python-list': 0.32;
'subject:for': 0.33; 'there': 0.33; '0);': 0.33; 'rgb(0,': 0.33;
'work.': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'auto;':
0.36; 'those': 0.36; 'special': 0.37; 'using': 0.37; "it's": 0.37;
'class': 0.37; 'way': 0.38; 'could': 0.38; 'least': 0.39; 'use':
0.39; 'neither': 0.39; 'to.': 0.39; 'wed,': 0.39; 'define': 0.40;
'something': 0.40; 'font-family:': 0.60; 'inline': 0.61; 'method':
0.61; 'me.': 0.62; 'display:': 0.62; 'widows:': 0.62; 'none;':
0.62; 'url-ip:151.101.0/24': 0.62; 'url-ip:151.101.128/24': 0.62;
'url-ip:151.101.192/24': 0.62; 'url-ip:151.101.64/24': 0.62;
'url:user': 0.62; 'font-weight:': 0.62; 'email addr:gmail.com':
0.63; 'simply': 0.63; '0px;': 0.63; 'url:gmail': 0.64; 'orphans:':
0.64; '0px;"': 0.64; 'text-indent:': 0.64; 'similar': 0.65;
'look': 0.65; 'normal;': 0.66; 'exactly': 0.68; 'order': 0.69;
'alle': 0.69; 'none;"': 0.69; 'received:mail-lf1-x12d.google.com':
0.69; 'slots': 0.69; 'subject:other': 0.69; "you'll": 0.73;
'float:': 0.74; 'href=""': 0.84; 'attribute': 0.84; 'catch': 0.84;
'dom': 0.84; 'email name:&lt;python-list': 0.84; 'received:88':
0.84; 'url:dispatch': 0.84; 'utc+2': 0.84; 'want.': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20221208; t=1691165273; x=1691770073;
h=references:to:cc:in-reply-to:date:subject:mime-version:message-id
:from:from:to:cc:subject:date:message-id:reply-to;
bh=C9M6gMqqIlqs3MC6MLpmyuhKxmJThNAsu8O2CrEkkXc=;
b=Advb6ExaaHKXdTMmjjfMaODct1fe8O+Ftnntg7Exck4gpnF3oQxjkjRS+uSJqwXYZq
6qxMrvm1rT5ths4zAsTP9lMKEgxDACSQ2DLvHy9rAbaFWF/zsfjtjrsa5lmO8iAXm5X6
bpCIJLPr4TpyVSCFXpOCfaTsWdmAe9y4aqeyqdmnifz+q5oG/bVdYVIveOj1tgk03R+z
AN2uh2/n5sGk1Xlyd7HRCGTXJ+e9Mav5SutGym0UWAJbGFTH2CPWcebYj3rfBI/btfI3
uHslGhmk6hsUfAkZyDErEsRmJmxy2bO6CReR6iLNmMn2bx2CFKQjBeamd0hguL7ChJap
zLAA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20221208; t=1691165273; x=1691770073;
h=references:to:cc:in-reply-to:date:subject:mime-version:message-id
:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=C9M6gMqqIlqs3MC6MLpmyuhKxmJThNAsu8O2CrEkkXc=;
b=GMRGmNPl2dOiusmFCaT4WRgDyqV2YQsA2F8DzrtcTPjX6Oonci0qj3TiWPtfd+FsBm
09bRWErCgGNXFrodpkKS9B2IFiwBKFOU2uG/1q/IhI+lu0kAO+ajZvHrPH2V4EkUkEnk
C6XQI68RO42TRrLBBZHXBoNlSxQaACVHg4iK/JYFurXToL2rnGKvroSbWDhKRmIZREPp
XEDE8pch3aMj9PSyj2wz2D1cfTRRMb7TXX90cBP2jJ9WBlZmfkXTZEbg1O07Y3kFMAoc
5W5EtPYRLQeLCBgyAkpLerDazL2gGAv80mh47erm+zoDHMQM2ZAplUPUf6Mti6te/7Ix
W7Fg==
X-Gm-Message-State: AOJu0Yx9i99HLi6pPJx0sqvdP7VJaTSMqhTJa9JCVH5G52+OQvZas728
WVWfro1tz4HShssFBo0ujqyGqtj0a54=
X-Google-Smtp-Source: AGHT+IGFTaSAsr01ALqqbSG+zl29LmVHGd20yGXwtAcsexEpqywkeX+Ws1IDlxG/MXt7CQ9hhgiU7g==
X-Received: by 2002:a05:6512:3e07:b0:4fc:3755:37d9 with SMTP id
i7-20020a0565123e0700b004fc375537d9mr2159141lfv.68.1691165272942;
Fri, 04 Aug 2023 09:07:52 -0700 (PDT)
In-Reply-To: <acbcc12f-e2e3-4d59-8623-3beb6dabe93fn@googlegroups.com>
X-Mailer: Apple Mail (2.3654.120.0.1.15)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <3DDEF864-9301-438A-9895-04D8D4A2A614@gmail.com>
X-Mailman-Original-References: <2D6F0153-5FAE-49A1-A5B0-23CF9AAED4E7@gmail.com>
<CAPTjJmoRd8psQmC+urJAE5QRM8st3_ihv3v8ODQNjRLEiPHfRA@mail.gmail.com>
<333FA876-8F7B-42D1-BD5C-6AEB07EE03BB@gmail.com>
<9EB0B006-9309-42EE-8D60-A6EF12B0B1BF@gmail.com>
<CAPTjJmok3z54bFSAD5-pSr0ff8aMKruxn95q+nENM5cjDeoePg@mail.gmail.com>
<mailman.199.1690396529.23016.python-list@python.org>
<acbcc12f-e2e3-4d59-8623-3beb6dabe93fn@googlegroups.com>
 by: Dom Grigonis - Fri, 4 Aug 2023 16:07 UTC

The issue was more of a wrapping around numpy array. Found the solution already. Unfortunately, there is no equivalent to __getattr__, the only way is to dynamically define them from meta. It seems it’s pretty standard to just have a collection of special method names and using them for similar cases. Well, at least it’s what I got to. __getattr__ feels very hacky for such case, so maybe it’s for the best.

> On 2 Aug 2023, at 19:54, Edmondo Giovannozzi via Python-list <python-list@python.org> wrote:
>
> Il giorno mercoledì 26 luglio 2023 alle 20:35:53 UTC+2 Dom Grigonis ha scritto:
>> Tried exactly that and didn’t work. Neither __getattr__, nor __getattribute__ of meta is being invoked.
>>> On 26 Jul 2023, at 10:01, Chris Angelico via Python-list <pytho...@python.org <http://python.org/>> wrote:
>>>
>>> On Wed, 26 Jul 2023 at 16:52, Dom Grigonis <dom.gr <http://dom.gr/>...@gmail.com <http://gmail.com/>> wrote:
>>>>
>>>> Could you give an example? Something isn’t working for me.
>>>>
>>>
>>> This is a metaclass:
>>>
>>> class Meta(type):
>>> ...
>>> class Demo(metaclass=Meta):
>>> ...
>>>
>>> In order to catch those kinds of attribute lookups, you'll need the
>>> metaclass to hook them. And you might need to use __getattribute__
>>> rather than __getattr__. However, there may also be some checks that
>>> simply look for the presence of the attribute (see: slots), so you may
>>> find that it's even more complicated. It's usually easiest to just
>>> create the slots you want.
>>>
>>> ChrisA
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>
>
> For numpy arrays you can find some suggestion at:
> https://numpy.org/doc/stable/user/basics.dispatch.html <https://numpy.org/doc/stable/user/basics.dispatch.html>
> --
> https://mail.python.org/mailman/listinfo/python-list <https://mail.python.org/mailman/listinfo/python-list>


devel / comp.lang.python / Re: Fallback for operator and other dunder methods

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor