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.26.1711382694.3468.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.26.1711382694.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: Mon, 25 Mar 2024 12:04:48 -0400
Lines: 109
Message-ID: <mailman.26.1711382694.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>
 <874jcustc4.fsf@zedat.fu-berlin.de>
 <004901da7ece$29b3e870$7d1bb950$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de bWXgUEo/RS5JygbiwlmwkwudB8OMxH1yaPP/0ugueJyQ==
Cancel-Lock: sha1:8ZpdMRx7ADe7iR1vEsUB+aOzwVE= sha256:8OcPJnH6rGZrhios2KkeAQAdWFb4NhGtfKK+umORH+o=
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=aYKe1MLC;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'def': 0.04; 'fairly':
 0.05; 'indicate': 0.05; 'that?': 0.07; ':-)': 0.09; 'cc:addr
 :python-list': 0.09; 'derived': 0.09; 'ended': 0.09; 'minus':
 0.09; 'received:108': 0.09; 'trivial': 0.09; 'writes:': 0.09;
 'cheers,': 0.11; 'cc:no real name:2**0': 0.14; '2024': 0.16;
 '>>>>': 0.16; 'bennett': 0.16; 'choices.': 0.16; 'collection.':
 0.16; 'column': 0.16; 'columns': 0.16; 'dict': 0.16;
 'dictionary,': 0.16; 'dicts': 0.16; 'idiom': 0.16; 'ignored':
 0.16; 'indeed': 0.16; 'intact': 0.16; 'iterate': 0.16; 'key-
 value': 0.16; 'method?': 0.16; 'nested': 0.16; 'odd': 0.16;
 'sets.': 0.16; 'skip:. 20': 0.16; 'structures': 0.16; 'variant':
 0.16; 'ways.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values':
 0.17; 'instead': 0.17; 'message-id:@gmail.com': 0.18;
 'cc:addr:python.org': 0.20; 'language': 0.21; 'languages': 0.22;
 'doubt': 0.22; 'way.': 0.22; 'skip:- 10': 0.25; 'cc:2**0': 0.25;
 'tried': 0.26; 'object': 0.26; 'suspect': 0.26; 'leave': 0.27;
 'else': 0.27; 'bit': 0.27; 'done': 0.28; 'thinking': 0.28;
 'keeping': 0.28; 'wrong': 0.28; 'seem': 0.31; 'modify': 0.31;
 'think': 0.32; 'assume': 0.32; 'concept': 0.32; 'do.': 0.32;
 'extract': 0.32; 'modified': 0.32; 'returning': 0.32; 'but': 0.32;
 'there': 0.33; 'march': 0.33; 'able': 0.34; 'header:In-Reply-
 To:1': 0.34; 'received:google.com': 0.34; 'complex': 0.35; 'felt':
 0.35; 'item': 0.35; 'from:addr:gmail.com': 0.35; 'functions':
 0.36; 'people': 0.36; 'lists': 0.37; 'currently': 0.37;
 'subject:from': 0.37; 'using': 0.37; 'others': 0.37; 'could':
 0.38; 'two': 0.39; 'adding': 0.39; 'single': 0.39; 'enough': 0.39;
 'use': 0.39; 'methods': 0.39; 'rest': 0.39; 'still': 0.40;
 'explain': 0.40; 'processed': 0.40; 'something': 0.40; 'want':
 0.40; 'including': 0.60; 'method': 0.61; 'from:': 0.62; 'to:':
 0.62; '25,': 0.62; 'here': 0.62; 'ever': 0.63; 'email
 addr:gmail.com': 0.63; 'simply': 0.63; 'copy': 0.63; 'everything':
 0.63; 'hear': 0.64; 'key': 0.64; 're:': 0.64; 'remains': 0.64;
 'thus': 0.64; 'your': 0.64; 'supply': 0.65; 'similar': 0.65;
 'well': 0.65; 'decided': 0.67; 'guaranteed': 0.67; 'right': 0.68;
 'items': 0.68; 'revert': 0.68; 'order': 0.69; 'cc:': 0.69;
 'order.': 0.69; 'remaining': 0.69; 'del': 0.70; 'costs': 0.74;
 'signature': 0.76; 'sent:': 0.78; 'major': 0.78; 'out.': 0.80;
 'left': 0.83; 'practical': 0.84; 'became': 0.84; 'exclusion':
 0.84; 'ordered': 0.84; 'pipeline': 0.84; 'received:mail-
 qk1-x735.google.com': 0.84; 'opposite': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1711382691; x=1711987491; darn=python.org;
 h=thread-index:content-language:content-transfer-encoding
 :mime-version:message-id:date:subject:in-reply-to:references:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=F0SjZ+AXaPwUj4uQt5zkQ3mvCYLbVsVoMZAYSLWFWhk=;
 b=aYKe1MLCmG/BBQLDNK+qMH3CYgglu60Qm1lFeIrYDgHGvwZrz2YncCe5iM4sxjUnJ6
 MgN1jQ36+ZQXXZ54DH8KcWyw97SwP7i/s8nAsZApaHypOPVuIfjR9StIPEPDMFjZS3XF
 wlDIXC3ZFgqDyQ+9qM/4Gb7BL875M/A1wUtcfMC0+cx/etaxb/DVQIAA4LU8aHEHfEfl
 iUB8mMY4e/j6iw2EDw9t82Oh8RTK9UsYUyiREw+2nO0lsUBs6/O4SdA7r/GQIsKzWdf+
 rvGkIXAAOgl4/TFoFJA4pKH0ZNoklYDbH8AMZTtvNhqMlOpHWpkTqzeRCc3qTYRC5beL
 fXkw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711382691; x=1711987491;
 h=thread-index:content-language:content-transfer-encoding
 :mime-version:message-id:date:subject:in-reply-to:references:cc:to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=F0SjZ+AXaPwUj4uQt5zkQ3mvCYLbVsVoMZAYSLWFWhk=;
 b=uQKXh82DO56XzokGyhqrhU8LF+rTloQLPDy2TGoO8tNz559T9AbIVYA9GIbI9QzhcD
 yPcuQzBRX2VFUTqygIKbnm3TOimzFGpdCLu244AqbnIsO7UlBJ/4M7xRJ63TAvQvvw4t
 ehVvKnui9x6mOwO+uew/4njoRUqh8PP35UQDA5v+MayylwpLfVuF3C17fYUGZ8HKTIMh
 StsYfc+ONDXXOt2Da/ZgJb8qFQuBTSG4z1IElCTQjkR1k/+3IIOm7Y+UacpbLj0t1j4B
 rDfnKvZqNWzFsSDRGtd7A1kpe2UM+bj3HADTrR/AM0wiSUORheUL69NyyGSkw24qNlSm
 UfAQ==
X-Gm-Message-State: AOJu0Yw4gamM0uK4sPf2kFkQ54snQH1/KW3gCZA2bVeO7/xxMFceGYRB
 uB046o1B/16G31fTeoI+ZJZrJtus0JxF7q2K2tmbhjVGTcCE2epm
X-Google-Smtp-Source: AGHT+IHTLGS+O8UXxSvA57gX2+oTVsswuptkxLwgsi/2sBRcrWfqohlgLLZof2JTdtJWGNqqBV2SUA==
X-Received: by 2002:a05:620a:1279:b0:78a:4338:7956 with SMTP id
 b25-20020a05620a127900b0078a43387956mr7700793qkl.34.1711382690899; 
 Mon, 25 Mar 2024 09:04:50 -0700 (PDT)
In-Reply-To: <874jcustc4.fsf@zedat.fu-berlin.de>
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-us
Thread-Index: AQKM7iLteXOq+KoZ2KtNA4Zjj8pI1wKmK1mHAVVm8JoB61U1HAHbvCMVr6WflpA=
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: <004901da7ece$29b3e870$7d1bb950$@gmail.com>
X-Mailman-Original-References: <87zfurgb6t.fsf@zedat.fu-berlin.de>
 <uti7n1$2ef92$1@dont-email.me>	<87plvmr93v.fsf@zedat.fu-berlin.de>	<005a01da7c84$4b9ba5f0$e2d2f1d0$@gmail.com>
 <874jcustc4.fsf@zedat.fu-berlin.de>
Bytes: 11304

I am glad, Lori, you found a solution another way.

Actually, Lori, I think you were right in looking for a built-in method =
that complements pop() by returning everything else other than the item =
mentioned. There are philosophical and practical considerations that =
were no doubt considered and a reality that the functionality did exist =
albeit not in a pipelined format.

Consider a language like LISP which sort of processed lists of things in =
which a major concept was getting the first item or getting all the =
rest. Lots of LISP programs had complex structures using CAR() and CDR() =
nested various ways to say extract the third item as CAR(CDR(CDR(X))) to =
the point where some commonly used combos became functions with names =
like CADDR().

There are again many languages where functions or methods are available =
that include an exclusion variant from a collection perhaps by doing =
something as simple as using a minus sign to indicate what to remove, as =
is commonly done in R to remove a column in a data.frame while keeping =
the order of the remaining columns the same.

Lots of languages had similar concepts about ordered data structures but =
dictionaries may be a bit of something else and initially in Python were =
not guaranteed to have any kind of order. Python dicts are more like =
unordered sets.=20

So although there remains a concept of not first/rest but this/rest,  I =
suspect there was some thought about the process that ended in deciding =
not to supply some functionality. When you use pop() on something like a =
large dictionary, the original is left intact and is ignored and a copy =
of a single element is made and returned. To do  the opposite and return =
the rest has two choices. One is to make a big copy of the rest of the =
dictionary and the other is to use del internally and return the =
modified dict. The functions you could write do the latter.

So why not add one or more methods to do that? Who knows? But I think =
some may have considered it not needed including some who felt no need =
for a pipeline method when del would do. Another consideration was the =
common idiom for iterating on a collection. Besides pop() you can get =
lists of dictionary entries, keys or values that you can work with and =
you can even iterate with "for key in dict: ..."

Given how many ways common things can be done, and given that adding too =
many methods has costs including new users not understanding all the =
nuanced differences, this fairly useful functionality was left out.

Unfortunately, I think they were wrong here as instead we hear often =
from people like you who assume things would work other ways. I still =
think it would be simple enough to have had a .removekeys(keys) that =
would work in a pipeline to modify the dict by removing one or more =
items and perhaps another .removevalues(values) but at some point you =
may keep adding methods nobody ever uses. The reality is that many =
trivial one-liner comprehensions can easily do many such things using =
iteration.=20

But many simply do not work well in pipelined fashion and thus may need =
to be embedded in a method of your own by subclassing dict or rolling =
your own.



-----Original Message-----
From: Loris Bennett <loris.bennett@fu-berlin.de>=20
Sent: Monday, March 25, 2024 2:45 AM
To: avi.e.gross@gmail.com
Cc: python-list@python.org
Subject: Re: Popping key causes dict derived from object to revert to =
object

<avi.e.gross@gmail.com> writes:

> 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.
>
========== REMAINDER OF ARTICLE TRUNCATED ==========