Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.16.1711131063.3468.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.16.1711131063.3468.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail
From: <avi.e.gross@gmail.com>
Newsgroups: comp.lang.python
Subject: RE: Popping key causes dict derived from object to revert to object
Date: Fri, 22 Mar 2024 14:11:00 -0400
Lines: 26
Message-ID: <mailman.16.1711131063.3468.python-list@python.org>
References: <87zfurgb6t.fsf@zedat.fu-berlin.de> <uti7n1$2ef92$1@dont-email.me>
 <87plvmr93v.fsf@zedat.fu-berlin.de>
 <005a01da7c84$4b9ba5f0$e2d2f1d0$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de kD3j3cQjJDOztQBjJZwGCwPX9xVvRfWJpTGxiYKWXHAA==
Cancel-Lock: sha1:Of9zgaVaAzu7suxWETaqX/S+H2g= sha256:5egGY5jP7dD7OxFST1P/EMMtsTPIYBuj8Y5rLGBx28o=
Return-Path: <avi.e.gross@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=mI7ScEAD;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'def': 0.04; 'minus': 0.09;
 'received:108': 0.09; 'trivial': 0.09; 'dict': 0.16; 'key-value':
 0.16; 'method?': 0.16; 'odd': 0.16; 'variant': 0.16; 'wrote:':
 0.16; 'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20;
 'tried': 0.26; 'leave': 0.27; '>>>': 0.28; 'thinking': 0.28;
 'seem': 0.31; 'concept': 0.32; 'but': 0.32; 'there': 0.33; 'able':
 0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
 'item': 0.35; 'from:addr:gmail.com': 0.35; 'subject:from': 0.37;
 'received:209.85': 0.37; 'others': 0.37; 'received:209': 0.39;
 'adding': 0.39; 'use': 0.39; 'received:209.85.222': 0.39;
 'explain': 0.40; 'want': 0.40; 'your': 0.64; 'similar': 0.65;
 'del': 0.70
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1711131061; x=1711735861; darn=python.org;
 h=thread-index:content-language:content-transfer-encoding
 :mime-version:message-id:date:subject:in-reply-to:references:to:from
 :from:to:cc:subject:date:message-id:reply-to;
 bh=zOz/KX8gsrD5I89b7nJ60tb2HJnEh+ZceQnsuccHDk8=;
 b=mI7ScEAD5i+eHh4aMzQHogXaRNw0PU/YE9RfvmpiIwo/AAQSraNPh7kt+JgZSSGwGG
 7u2skWTzRTIQTcmmnwnRZKd/00semR0wSTg722JzrESumtOmVhN5BF4bAC99RGIwcGMt
 jTklSA19rDiko3khsjZKzE1SukA9Xeb7GhWvzEpG9wQJBFu/bCja9sBI4Wfj0s/Y6HkR
 zFsBoFQr+/3hObGpnFzs92JEl4wdzpPjzlp2I3OkC4/VfQYIELlN21QsP7EnjVPePnSp
 iJmTlVBkqgb/EDacLcibU5+ibptKBqqhm+DschOjxS8VhfGMIGTxcOEnnoWjWPGO50s/
 v01Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711131061; x=1711735861;
 h=thread-index:content-language:content-transfer-encoding
 :mime-version:message-id:date:subject:in-reply-to:references:to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=zOz/KX8gsrD5I89b7nJ60tb2HJnEh+ZceQnsuccHDk8=;
 b=eBL5OXAJMhrhThYOF5fqeAeEel+XXePQzLMYo4P5uHCsHTtNoX/8gdWjqwbhQQrTdh
 XCZWAUZj84/yZT3AK5Vl2VmQHwtz01zLMfTlMF5/RnvuRItNSuo4GWWHwoIuKjMOjXSb
 FYyPpG0Tn3aXA9RBwqh2bna5wvtzoiMVWz/nqseYrZ+BD+o1cxtnlgDnGhlZGjFTPIOE
 c400iX9tgN7nAz7b6sXrZNsC3hKOs5yZ3VKupgp5Gd06jBOJm/0wvFOwMqEZ/W9vAvYy
 bO6vyM7mR5GqULcndlcGxM7qd6MVJaPidwAKj00sHgy/Ye6SiI0X7N3D1gxTnxWKiiAa
 CSyA==
X-Forwarded-Encrypted: i=1;
 AJvYcCU7zmWp4fFJrDYWqYEI8eNhjfW4PJKoKfJT+wsUin0vBYbdDNaHAbunLMJgKvRCfw/blrRjoGbZZBMEtXklV24YphnNXyHD
X-Gm-Message-State: AOJu0Yw2HsWSXsUFElbepd6mAByxAN3cAcLIgNRt9mRBgwp8R9PmbcFd
 kj+7BSh8F0rgHlYAEP3dg3NsYdsurY6G6WKrrvqCT7gkLf3GL5M5ARQHh4+c
X-Google-Smtp-Source: AGHT+IEwACass8gvJ3AEye1ZqEoIjQ3fbvq9k9Xb/s+3Ia005OvLzBINxz+DNjItkV7T9cNJhb6f4g==
X-Received: by 2002:a05:620a:b96:b0:788:7622:ceb2 with SMTP id
 k22-20020a05620a0b9600b007887622ceb2mr516827qkh.18.1711131061473; 
 Fri, 22 Mar 2024 11:11:01 -0700 (PDT)
In-Reply-To: <87plvmr93v.fsf@zedat.fu-berlin.de>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQKM7iLteXOq+KoZ2KtNA4Zjj8pI1wKmK1mHAVVm8Jqvv01YYA==
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: <005a01da7c84$4b9ba5f0$e2d2f1d0$@gmail.com>
X-Mailman-Original-References: <87zfurgb6t.fsf@zedat.fu-berlin.de>
 <uti7n1$2ef92$1@dont-email.me> <87plvmr93v.fsf@zedat.fu-berlin.de>
Bytes: 5580

Loris wrote:

"Yes, I was mistakenly thinking that the popping the element would leave
me with the dict minus the popped key-value pair.  Seem like there is no
such function."

Others have tried to explain and pointed out you can del and then use the
changed dict.

But consider the odd concept of writing your own trivial function.

def remaining(adict, anitem):
  _ = adict.pop(anitem)
  # alternatively duse del on dict and item
  return adict


>>> remaining({"first": 1, "second": 2, "third": 3}, "second")
{'first': 1, 'third': 3}


Or do you want to be able to call it as in dict.remaining(key) by
subclassing your own variant of dict and adding a similar method?