Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You can't cheat the phone company.


devel / comp.lang.python / Re: Is there a way to implement the ** operator on a custom object

SubjectAuthor
o Re: Is there a way to implement the ** operator on a custom objectLeft Right

1
Re: Is there a way to implement the ** operator on a custom object

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: olegsivo...@gmail.com (Left Right)
Newsgroups: comp.lang.python
Subject: Re: Is there a way to implement the ** operator on a custom object
Date: Fri, 9 Feb 2024 17:09:54 +0100
Lines: 12
Message-ID: <mailman.55.1707495910.3227.python-list@python.org>
References: <c40b43e5-12e7-4495-a876-10362a19007c@btinternet.com>
<ZcW9HVRqhiR53tcT@cskk.homeip.net>
<CAPTjJmo4_ay1eY9e-AXNXsCY8T6bgk9LQoKZ91DsaHxLvgegWw@mail.gmail.com>
<CAJQBtg==mLmO+gj_75yrr-JQB-xe3joo7HZM70E8MiX5bemWaw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de PU0Opn7Pzn8l0J0AWcOrmwDNU/kZlyLdAmvTbYv6n0zQ==
Cancel-Lock: sha1:xDkBkxJkgERTo9eOWyw/h0pmsoM= sha256:YhEl052GBzNaAqRDMEj2RYAfBhGkFPBy3ecIpRuKQhA=
Return-Path: <olegsivokon@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=T//VFYY+;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.069
X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'populate': 0.09; 'skip:`
10': 0.09; 'that.': 0.15; 'indeed': 0.16; 'slot': 0.16;
'subject:way': 0.16; 'python': 0.16; 'probably': 0.17; 'bug':
0.19; 'to:addr:python-list': 0.20; 'cannot': 0.25; 'object': 0.26;
'seem': 0.31; 'think': 0.32; "doesn't": 0.32; 'subject:there':
0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'work,': 0.36; 'received:209.85':
0.37; 'file': 0.38; 'way': 0.38; 'could': 0.38; 'received:209':
0.39; 'mentioned': 0.39; 'methods': 0.39; 'try': 0.40; 'research':
0.64; 'produce': 0.65; 'order': 0.69; 'type:': 0.69; 'supposed':
0.76; 'further,': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1707495006; x=1708099806; darn=python.org;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=3xxGrjny2z4wdHJxSAiuHfr9kIbBmqhwkreYMKbvX4I=;
b=T//VFYY+EZF3CIFo6GO7E6g/Up9SGhpqjvONpq6lLU7e8CLM//1kPpyAaQULP9q1wu
xGsxp5DK2ezjwuMv2ftGcLWveKCM22NkWkYBQJznYFZH9Qa+3M2rggwvmD2k+3wWmdNk
ecP4CA9UWS+ZAOBUl/vrdC0SpWBXD+ByOQgsa8ECwt8xzd9ul8FIF65aseVMmMs6s1C/
izYowMs05s3bWMO+yw4EJuu2wOFLIJYnDFp7JCiWpo7sl6Cm9eNZmujAa4IAEs+wW4Ah
9y15KMeiJ4E9sG4+SKYG98A96rWppBWlPKrqi/36RsOR9l3nlRWjxRi+e70Wu8rSlZR0
cD2Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1707495006; x=1708099806;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=3xxGrjny2z4wdHJxSAiuHfr9kIbBmqhwkreYMKbvX4I=;
b=cV4rWg4dljNwKtjb9K0ZJZvzWo762+RXVfZ8yxQWOKDGA1+5NwBDrx/RMlsqcOWyHq
NgwDAJYNXh9IPWq1ylOgklRIdGFmrXwj0VZsyQxaJ/myvNy5g9GJhuMZk3X6U6pQL+v1
ZB5GTFSeM7mxnA4FOttisyZ3Y5ehlydrZko792epPVqXY7GtYecFSHm3uMW/mOq9cPjW
82uW/6Pa9UrcOdPtjE30wJhwCMKjHxuzTLKb5RuMbyAQjx2pGPNCq2BpPSNjC1zMsaab
u9GKz3PC8NwT8V/EveqCDzLddT4SFGmZvrmr+pEJ646AuZYT38Af1z2zFs1QeIJsRBfU
j14w==
X-Gm-Message-State: AOJu0YzQXyUs/MYsImtF5w8R4CC/VVQAGJhcA3mmBpm1+KrQq6gjN84Q
JCK4BOq3aPEMJ5eYB2do7u+N7l+4388KX9+ONQBhYL6OpgqnNME7ZWNALCIGlzuvNpVDlTqQ0el
IsSHq9F5UifdCo+86BrcgLBshru6liVSXRbU=
X-Google-Smtp-Source: AGHT+IGaXbp2UI26iAJiAJht+orSx6i4ZJBx+9KJlKLpFUUR88ZNAU8YxStKEuXZ1f7yymhTnYSFjrbnjSTAhgV5arA=
X-Received: by 2002:a05:6808:3195:b0:3be:9ae8:16be with SMTP id
cd21-20020a056808319500b003be9ae816bemr2679093oib.38.1707495005945; Fri, 09
Feb 2024 08:10:05 -0800 (PST)
In-Reply-To: <CAPTjJmo4_ay1eY9e-AXNXsCY8T6bgk9LQoKZ91DsaHxLvgegWw@mail.gmail.com>
X-Mailman-Approved-At: Fri, 09 Feb 2024 11:25:09 -0500
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: <CAJQBtg==mLmO+gj_75yrr-JQB-xe3joo7HZM70E8MiX5bemWaw@mail.gmail.com>
X-Mailman-Original-References: <c40b43e5-12e7-4495-a876-10362a19007c@btinternet.com>
<ZcW9HVRqhiR53tcT@cskk.homeip.net>
<CAPTjJmo4_ay1eY9e-AXNXsCY8T6bgk9LQoKZ91DsaHxLvgegWw@mail.gmail.com>
 by: Left Right - Fri, 9 Feb 2024 16:09 UTC

In order for the "splat" operator to work, the type of the object must
populate slot `tp_as_mapping` with a struct of this type:
https://docs.python.org/3/c-api/typeobj.html#c.PyMappingMethods and
have some non-null implementations of the methods this struct is
supposed to contain.

I can do this in C, but I cannot think of a way to do this in Python
proper. Defining all the methods mentioned in PyMappingMethods doesn't
seem to do it. You could try to research this further, and if, indeed
defining all the methods of PyMappingMethods on the Python side
doesn't produce an object that behaves like a proper mapping, you
could probably file a bug report for that.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor