Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If you can't understand it, it is intuitively obvious.


devel / comp.lang.python / If a dictionary key has a Python list as its value!

SubjectAuthor
* If a dictionary key has a Python list as its value!Varuna Seneviratna
`- Re: If a dictionary key has a Python list as its value!Stefan Ram

1
If a dictionary key has a Python list as its value!

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: varunaseneviratna@gmail.com (Varuna Seneviratna)
Newsgroups: comp.lang.python
Subject: If a dictionary key has a Python list as its value!
Date: Thu, 7 Mar 2024 19:41:11 +0530
Lines: 14
Message-ID: <mailman.59.1709834551.3452.python-list@python.org>
References: <CAKW-c0x7-r_HtTkb0NdhQx7_Yo1fSfGdvOqBOcq_LdoSYdt57Q@mail.gmail.com>
Reply-To: varuna.seneviratna@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de m7upJ/QK2iDgUKpSRRdJVAoYsx+LASnOlG+Nb+sdpbNw==
Cancel-Lock: sha1:lCC2NMVqaVXeeEQYGPQR+Ns2wps= sha256:Efq+tzzNcn1//EimfB9p7MwO4ztrb5LfHTp9Hk4tESQ=
Return-Path: <varunaseneviratna@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=TAlKKaOK;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.037
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.01; 'explanation': 0.07;
'subject:value': 0.07; 'subject:list': 0.11; 'subject:Python':
0.12; 'tutorial': 0.12; 'following.': 0.16; 'received:mail-
ed1-x52f.google.com': 0.16; 'python': 0.16; 'values': 0.17;
'to:addr:python-list': 0.20; 'message-id:@mail.gmail.com': 0.32;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'using':
0.37; 'read': 0.38; 'this,': 0.39; 'list': 0.39; 'key': 0.64;
'subject:!': 0.76; 'reply-to:no real name:2**0': 0.78; 'header
:Reply-To:1': 0.79; 'reply-to:addr:gmail.com': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1709820684; x=1710425484; darn=python.org;
h=to:subject:message-id:date:from:reply-to:mime-version:from:to:cc
:subject:date:message-id:reply-to;
bh=phCuO6qzJgVq2DgqTvolQGerXNKGQ1LvLnhHoLBXVJE=;
b=TAlKKaOKfxEEigfeJ9kTRzaCRRDWhOzzOfPg9iwWUD5dgIg2MdKFd4ujIE0fTfvQeH
46+MvR5+RStBCKFQ1WoruXzNtBoKn40vdn9sI2snt14CDvBJGn9FWHcJwMSUoS9CsW3h
QQ4I9Ef0gE7o++MfhwzDYsawXRq/R2MWq9KMEUO5XUSnsDJ/ouUTDeLo6nzNdukAyjWr
wTs9Prq9K0Cp3wnDuavw6nYebyBy40WPkZU8QvDG8XLYsiQFI7xnvy2S3wRvXRD8BHRQ
gsV6PbRLGzyi90rViJf/XqWayNO8Zk3rHnN0Hf8cfQq3p4gtc7d7LYeisluxJZYWDiJJ
5/cQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1709820684; x=1710425484;
h=to:subject:message-id:date:from:reply-to:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=phCuO6qzJgVq2DgqTvolQGerXNKGQ1LvLnhHoLBXVJE=;
b=Qw12cJ2bzjKEXz/6qJ6ApUtyu2Ebz05Rt/zWKKwQM39F3J4T0UM30f+HVsV3IwhjCK
aUd7adfVtnbc9/ITIdMUutx/YTblID10lZ+K9Eve+D3KLRqWhDhYpw/SjR10S3on5lyM
a5LpHFSahCz6R0LdHxrmLNsZdTVcDSxtzdLkmAWbAFfrNU4IVs6eN2MR5MUHiI8JK9ar
+zzISDXbi1t3bIAO5exbOkySSUMRB/IBL8gW4DDzNVthBJH4/mlGxRIJt26zmE/B0MLF
kxxm9LUuv6sgzcrRR4aEc4Qi48iQ9BuIsCVYNldcuwnNpl3XUerz+pl0TGI/RMksNzZZ
+KRw==
X-Gm-Message-State: AOJu0YycbYbWIRU/Nm9Qbx9keizvEhfym/iJA2hEjMWibMiRr/RXXduY
abDpO/15HVg3fsewTBLdzEtORzH5yHeg8/FE5KNalOpsvs6YHZYSWOiTPBcFVN8h//AlOyq0K8b
3ZF2ahwdN+bVE6BlcYqpFbYngLO8iCBBeQ7wt
X-Google-Smtp-Source: AGHT+IFM9lcn4hMJCMAZec4VTZZZSCbssb1S09WUB/V8E81dQRLMX7MSbxNeTVBAQK3rZzLHmHZMJ+O4Lefwv/Ko7Wo=
X-Received: by 2002:a17:906:4ac1:b0:a45:b1fc:463 with SMTP id
u1-20020a1709064ac100b00a45b1fc0463mr3964166ejt.34.1709820684291; Thu, 07 Mar
2024 06:11:24 -0800 (PST)
X-Mailman-Approved-At: Thu, 07 Mar 2024 13:02:30 -0500
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: <CAKW-c0x7-r_HtTkb0NdhQx7_Yo1fSfGdvOqBOcq_LdoSYdt57Q@mail.gmail.com>
 by: Varuna Seneviratna - Thu, 7 Mar 2024 14:11 UTC

If a dictionary key has a Python list as its value, you can read the values
one by one in the list using a for-loop like in the following.

d = {k: [1,2,3]}

> for v in d[k]:
> print(v)

No tutorial describes this, why?
What is the Python explanation for this behaviour?

Varuna

Re: If a dictionary key has a Python list as its value!

<tutorial-20240307202019@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: If a dictionary key has a Python list as its value!
Date: 7 Mar 2024 19:21:31 GMT
Organization: Stefan Ram
Lines: 20
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <tutorial-20240307202019@ram.dialup.fu-berlin.de>
References: <mailman.59.1709834551.3452.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de Q7ZLnUGTc96YZRnDIpZBiw2xsCapSKaha/pUmSDyitkBEa
Cancel-Lock: sha1:PxkCyepN65ovkGew1+8tM+y4rOY= sha256:2O96c0qj8vhSPpbWVEuIuRNNn0FQ7hrcm5/JHjHBKxk=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Thu, 7 Mar 2024 19:21 UTC

Varuna Seneviratna <varunaseneviratna@gmail.com> wrote or quoted:
>If a dictionary key has a Python list as its value, you can read the values
>one by one in the list using a for-loop like in the following.
>d = {k: [1,2,3]}
>> for v in d[k]:
>> print(v)
>No tutorial describes this, why?
>What is the Python explanation for this behaviour?

This is explained by extensionality: To find the behavior of
"for v in ...", the only thing one needs to know about "..."
is its value. You could just as well have written:

l = d[ k ]
for v in l:

. l can be any iterable. It does not matter where it came from.
It does not matter that it cam from a dictionary. There are thousand
places where it could have come from, and no tutorial can name them
all.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor