Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Oh, so there you are!


devel / comp.lang.python / Re: Configuring an object via a dictionary

SubjectAuthor
* Re: Configuring an object via a dictionarydn
`* Re: Configuring an object via a dictionaryGilmeh Serda
 +- Re: Configuring an object via a dictionaryRoel Schroeven
 `- Re: Configuring an object via a dictionary2QdxY4RzWzUUiLuE

1
Re: Configuring an object via a dictionary

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: Configuring an object via a dictionary
Date: Mon, 18 Mar 2024 10:09:27 +1300
Organization: DWM
Lines: 104
Message-ID: <mailman.113.1710709774.3452.python-list@python.org>
References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 424K9wjQkmEo69Z/fK8qAQo9HLTif4R0jlD5PUODXilg==
Cancel-Lock: sha1:Y02t6WAH6GnKPLdK1MIgHYfaTTI= sha256:C72pmUQ4AUD2rjl3u3zsQ0zPW49JgqTgDbp88uAKp9s=
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=Owl35FPG; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; '(for': 0.05;
'(to': 0.07; 'mar': 0.07; 'tests': 0.07; '=dn': 0.09; 'fails':
0.09; 'from:addr:danceswithmice.info': 0.09;
'from:addr:pythonlist': 0.09; 'meant': 0.09; 'thread:': 0.09;
'values.': 0.09; 'coding': 0.13; 'syntax': 0.15; '>>>>': 0.16;
'>>>>>': 0.16; 'barry': 0.16; 'below).': 0.16; 'corrected': 0.16;
'hand,': 0.16; 'holzer': 0.16; 'idiom': 0.16; 'message-
id:@DancesWithMice.info': 0.16; 'received:51.254': 0.16;
'received:51.254.211': 0.16; 'received:51.254.211.219': 0.16;
'received:cloud': 0.16; 'received:rangi.cloud': 0.16; 'self.name':
0.16; 'semantics': 0.16; 'useful.': 0.16; 'wrote:': 0.16;
'problem': 0.16; 'python': 0.16; 'instead': 0.17; 'to:addr:python-
list': 0.20; "i've": 0.22; 'maybe': 0.22; 'version': 0.23; 'code':
0.23; 'lines': 0.23; '(and': 0.25; "isn't": 0.27; 'else': 0.27;
'bit': 0.27; '>>>': 0.28; 'fact': 0.28; 'corporate': 0.29; 'header
:User-Agent:1': 0.30; 'seem': 0.31; 'header:Organization:1': 0.31;
'think': 0.32; 'gotten': 0.32; 'python-list': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'same': 0.34; 'header:In-
Reply-To:1': 0.34; 'meaning': 0.35; 'yes,': 0.35; 'fix': 0.36;
'those': 0.36; 'guide': 0.37; 'using': 0.37; 'received:192.168':
0.37; 'thanks': 0.38; 'two': 0.39; 'still': 0.40; 'above': 0.62;
'from:': 0.62; 'true': 0.63; 'our': 0.64; 'received:51': 0.64;
'your': 0.64; 'similar': 0.65; 'earlier': 0.67; 'primary': 0.67;
'interest': 0.70; 'raised': 0.70; 'production': 0.71; '....':
0.76; 'unusual': 0.81; 'left': 0.83; 'consequences': 0.84;
'exactly.': 0.84; 'suffering': 0.84; 'forces': 0.91;
'illustration': 0.91; 'sad': 0.91
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 13F754DD2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1710709771;
bh=FKINogpLBoFY1mvYeCQVAznt27XiTbdAOQijKpUNayE=;
h=Date:From:Subject:To:References:In-Reply-To:From;
b=Owl35FPGWv/s+7IwyqoSONq6UjnxFtVe4Z7oWXmDhXAiaTx7bdvelbqY/saq1H3/X
LW/FukKoWlr1E1HaAiNw3ZXM9uFj+FNn4zQPXD1ubuuxtxLZdT5aoYuKE5Xge1N9xU
RaKH7Wh3GIJHrAuB0jICDbOKG4fuHPBSlh7xlJIJY9Q8RHSl8jkSVa9/eLntxEj4qn
vdMN2WFFTCT4xdyorejRKUy5OxhszBdocXvOd0gWCGprQO78XOo8vwQ7nEMHIK4s0g
yXDF77SlWkYe347I0bXrFXi2fzTFyya8B/DXYQoJMKWYTCu6Jhr/R79jAQOLrbZJ4F
pCBmcVkZees6A==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <20240317151153.cgnsvd6hd7pb767r@hjp.at>
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: <9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
X-Mailman-Original-References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
 by: dn - Sun, 17 Mar 2024 21:09 UTC

On 18/03/24 04:11, Peter J. Holzer via Python-list wrote:
> On 2024-03-17 17:15:32 +1300, dn via Python-list wrote:
>> On 17/03/24 12:06, Peter J. Holzer via Python-list wrote:
>>> On 2024-03-16 08:15:19 +0000, Barry via Python-list wrote:
>>>>> On 15 Mar 2024, at 19:51, Thomas Passin via Python-list <python-list@python.org> wrote:
>>>>> I've always like writing using the "or" form and have never gotten bit
>>>>
>>>> I, on the other hand, had to fix a production problem that using “or” introducted.
>>>> I avoid this idiom because it fails on falsy values.
>>>
>>> Perl has a // operator (pronounced "err"), which works like || (or),
>>> except that it tests whether the left side is defined (not None in
>>> Python terms) instead of truthy. This still isn't bulletproof but I've
>>> found it very handy.
>>
>>
>> So, if starting from:
>>
>> def method( self, name=None, ):
>>
>> rather than:
>>
>> self.name = name if name else default_value
>>
>> ie
>>
>> self.name = name if name is True else default_value
>
> These two lines don't have the same meaning (for the reason you outlined
> below). The second line is also not very useful.
>
>
>
>> the more precise:
>>
>> self.name = name if name is not None or default_value
>>
>> or:
>>
>> self.name = default_value if name is None or name
>
> Those are syntax errors. I think you meant to write "else" instead of
> "or".
>
> Yes, exactly. That's the semantic of Perl's // operator.
>
> JavaScript has a ?? operator with similar semantics (slightly
> complicated by the fact that JavaScript has two "nullish" values).

Thanks Peter!
(yes, sad consequences of suffering a neighbor's party-til-midnight
followed by an 0530 meeting-start - children: don't code exhausted!)

Herewith, an illustration of how the corrected version of the above
works - and how (in what seem unusual cases) it avoids any truthy/falsy
confusion, as raised earlier in this thread:

>>> default_value = "default"
>>> name = "Fred Flintstone"
>>> name if name is not None else default_value
'Fred Flintstone'

>>> name = None
>>> name if name is not None else default_value
'default'
>>> name = False
>>> name if name is not None else default_value
False
>>> name = 1
>>> name if name is not None else default_value
1 >>> name = 0
>>> name if name is not None else default_value
0

Personally: I find the above coding more logical, because our primary
interest is on 'the happy case', ie where the value has been assigned
(to "name"); and the default_value is only applied as a "guard".

On the other hand, I dislike the not-condition because it forces me to
think (and maybe dust-off DeMorgan). Accordingly:

>>> name = "Fred Flintstone"
>>> default_value if name is None else name
'Fred Flintstone'
>>> name = None
>>> default_value if name is None else name
'default'
>>> name = False
>>> default_value if name is None else name
False
....

YMMV!
NB your corporate Style Guide may prefer 'the happy path'...

--
Regards,
=dn

Re: Configuring an object via a dictionary

<Tl4KN.1884424$Ko1.841285@fx05.ams4>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx05.ams4.POSTED!not-for-mail
From: gilmeh.serda@nothing.here.invalid (Gilmeh Serda)
Subject: Re: Configuring an object via a dictionary
Newsgroups: comp.lang.python
References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
<mailman.113.1710709774.3452.python-list@python.org>
MIME-Version: 1.0
x-no-archive: yes
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 20
Message-ID: <Tl4KN.1884424$Ko1.841285@fx05.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Mon, 18 Mar 2024 23:44:51 GMT
X-Received-Bytes: 1636
 by: Gilmeh Serda - Mon, 18 Mar 2024 23:44 UTC

On Mon, 18 Mar 2024 10:09:27 +1300, dn wrote:

> YMMV!
> NB your corporate Style Guide may prefer 'the happy path'...

If you only want to check for None, this works too:

>>> name = None
>>> dafault_value = "default"
>>> name or default_value
'default'
>>> name = 'Fred Flintstone'
>>> name or default_value
'Fred Flintstone'

--
Gilmeh

A little suffering is good for the soul. -- Kirk, "The Corbomite
Maneuver", stardate 1514.0

Re: Configuring an object via a dictionary

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: roel@roelschroeven.net (Roel Schroeven)
Newsgroups: comp.lang.python
Subject: Re: Configuring an object via a dictionary
Date: Wed, 20 Mar 2024 09:49:54 +0100
Lines: 40
Message-ID: <mailman.121.1710924599.3452.python-list@python.org>
References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
<mailman.113.1710709774.3452.python-list@python.org>
<Tl4KN.1884424$Ko1.841285@fx05.ams4>
<6a691f90-3198-47c8-bb35-62a789280ae7@roelschroeven.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de SpJr6N4M2tlky5WqnD+86AkeabErOvJDx65oaoqepK4A==
Cancel-Lock: sha1:GXu3qIhHrSV0eiOsOrjvWWL4X9Y= sha256:I4xWkTnYk0s6jf8ZrkxPjBLmda5G6bWOEN9bCPiR6Vg=
Return-Path: <roel@roelschroeven.net>
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=roelschroeven.net header.i=@roelschroeven.net
header.b=E2d6bdRd; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.042
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.01; 'mar': 0.07; 'rejected':
0.09; 'values.': 0.09; '2024': 0.16; 'received:10.202': 0.16;
'received:10.202.2': 0.16; 'received:internal': 0.16;
'received:messagingengine.com': 0.16; 'schreef': 0.16; 'wrote:':
0.16; 'to:addr:python-list': 0.20; '>>>': 0.28; 'corporate': 0.29;
'header:User-Agent:1': 0.30; 'header:In-Reply-To:1': 0.34; 'mon,':
0.36; 'guide': 0.37; 'though': 0.37; 'want': 0.40; 'your': 0.64;
'well': 0.65; 'acceptable': 0.69; 'reasons': 0.84; 'us,': 0.89;
'received:103': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
roelschroeven.net; h=cc:content-transfer-encoding:content-type
:content-type:date:date:from:from:in-reply-to:in-reply-to
:message-id:mime-version:references:reply-to:subject:subject:to
:to; s=fm1; t=1710924596; x=1711010996; bh=upIgq+mBxVI6VhllM7fnD
qFomy5MGDIuTg47o95ZYqE=; b=E2d6bdRd4EX/r5QQmhjBHUSiuRFvtIXaKHImU
dgI82euwVC8r3CRNglGoHxZ+N8xJm8a0fi5IQ3Dl0kR+rwBbTtESsAltSivBCJoB
SeFPhCUVRsuhna7YF6qT7TyMi+r9VNDPSLN/Aw53hlkb5k6VOU15HpoIIlCTHpnP
5O6L+3/+wvvKDhnDY3Q5Eiyp4UExtH2u40uKHGclhrkkVzV+PoOFQ834shR0broL
8I+o6U0Hcs8F+60R/6EgmD8YUJ03XgBZLgFMUAb9mMucixuuSJnXg7I/1T4Otc9a
3Y8CUwb4hiNIJ6CiGq3FE4Z15Q/JR6NJPH1NwWsTU9uXiZgsw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
messagingengine.com; h=cc:content-transfer-encoding:content-type
:content-type:date:date:feedback-id:feedback-id:from:from
:in-reply-to:in-reply-to:message-id:mime-version:references
:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy
:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1710924596; x=
1711010996; bh=upIgq+mBxVI6VhllM7fnDqFomy5MGDIuTg47o95ZYqE=; b=u
G3+prb4XKx6psNrGwTsJy4KgW0527UuGVsEWEwC1ZK1dHdmchB51x4yNr3B6Qm2E
k49Z9ckh/N4301DWmHoZ/THq8Joi3ZHuSj0afg5cViMma/b/A+7SSXO0Q61pqd7g
E7+HzlKEmwJrUenfBzLnd0BbdbTupHbOmsbygD2ziG7VuG/dYdlFn0918vRVsRbO
rz0jo9QGy+E0cnV58aqRqKI0IlFq3Jo21zBeXWn83LA87KFlrJLNpXr0yDj3/FUl
w+WvBmIIBLam3LTV2p1tIBSPtpRtXeaBETMjf2mFrs/KdLQPc/nlWEDA2iJRiWkQ
CQZ4xsv+nBc4NIA/b9yBA==
X-ME-Sender: <xms:NKP6ZXfr7MHnfDGfHBZYNytznBG9gr3F3X2VZTRV_uukYwD3IfEoDw>
<xme:NKP6ZdNHF_k1H7mPl8HOd37vamG27z-IRz2zpIaIvcLSPpIhTK82JPWmaH8mY4Cla
RYYN5Z1oE11>
X-ME-Received: <xmr:NKP6ZQh_VSFsAo07lrSx-3ptcurfYRG6-Zus-fUF8niMHILJcETqEO2vzduWWoa2hlET95WW01MCrnRmmcxvf9gSSqsx3AWxbYB4OjU1Ku8At1E>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrleefgdejvdcutefuodetggdotefrodftvf
curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthejre
dttddvjeenucfhrhhomheptfhovghlucfutghhrhhovghvvghnuceorhhovghlsehrohgv
lhhstghhrhhovghvvghnrdhnvghtqeenucggtffrrghtthgvrhhnpeekgfefudeuhedvke
efjeehvdeljeelfffhtdegteejtdeufeeffefhveetudffueenucevlhhushhtvghrufhi
iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgvlhesrhhovghlshgthhhroh
gvvhgvnhdrnhgvth
X-ME-Proxy: <xmx:NKP6ZY-yy1FuInhtotJWAm8whiMkagMZf3VUcJ_S4sUGFp8dr32V-g>
<xmx:NKP6ZTtFP7BYTYr4VcMAHFoDf-1p0uX4YsOEw41XGoOgI4gcOkXiOA>
<xmx:NKP6ZXEYbmAx93Dzaaq2qA-DZzXKx22bGcl7ZrZamaW_Sdz2PZesfg>
<xmx:NKP6ZaN_n_GrNqnR4sy2ysB6WjB-LVBUIsXY7UVR-Q7Qosv-hunf6g>
<xmx:NKP6Zc6eeWftPPBuFSOwOrYpxSqDULOtAEPCiyh5ia1noSgce2M_wg>
Feedback-ID: i8e5b41ae:Fastmail
User-Agent: Mozilla Thunderbird
Content-Language: nl, en-US
In-Reply-To: <Tl4KN.1884424$Ko1.841285@fx05.ams4>
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: <6a691f90-3198-47c8-bb35-62a789280ae7@roelschroeven.net>
X-Mailman-Original-References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
<mailman.113.1710709774.3452.python-list@python.org>
<Tl4KN.1884424$Ko1.841285@fx05.ams4>
 by: Roel Schroeven - Wed, 20 Mar 2024 08:49 UTC

Op 19/03/2024 om 0:44 schreef Gilmeh Serda via Python-list:
> On Mon, 18 Mar 2024 10:09:27 +1300, dn wrote:
>
> > YMMV!
> > NB your corporate Style Guide may prefer 'the happy path'...
>
> If you only want to check for None, this works too:
>
> >>> name = None
> >>> dafault_value = "default"
> >>> name or default_value
> 'default'
> >>> name = 'Fred Flintstone'
> >>> name or default_value
> 'Fred Flintstone'

>>> name = ''
>>> name or default_value
'default'

>>> name = False
>>> name or default_value
'default'

>>> name = []
>>> name or default_value
'default'

>>> name = 0
>>> name or default_value
'default'

You haven't only checked for None! You have rejected *every* falsish
value, even though they may very well be acceptable values.

--
"Most of us, when all is said and done, like what we like and make up
reasons for it afterwards."
-- Soren F. Petersen

Re: Configuring an object via a dictionary

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: 2QdxY4RzWzUUiLuE@potatochowder.com
Newsgroups: comp.lang.python
Subject: Re: Configuring an object via a dictionary
Date: Wed, 20 Mar 2024 05:28:24 -0400
Lines: 32
Message-ID: <mailman.122.1710926915.3452.python-list@python.org>
References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
<mailman.113.1710709774.3452.python-list@python.org>
<Tl4KN.1884424$Ko1.841285@fx05.ams4>
<6a691f90-3198-47c8-bb35-62a789280ae7@roelschroeven.net>
<ZfqsOE67ohrmrzks@anomaly>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de lvx6jVCuvHlJqnI+TQuRXgnCkUkCdvt3CDWAqk31tm4g==
Cancel-Lock: sha1:ZsRcq1Fty+tOOJpkZK4Rv5jt+V8= sha256:OhBG1Mfubb4F4xrQg0Lht0/g0XoG2mIMpF8XDO1+9Wg=
Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.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=potatochowder.com header.i=@potatochowder.com
header.b=V7ZoxyRy; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(e.g.': 0.05; 'file?':
0.05; "python's": 0.05; 'string': 0.07; ':-)': 0.09; 'quickly.':
0.09; 'received:78': 0.09; 'rejected': 0.09; 'roel': 0.09;
'schroeven': 0.09; 'test,': 0.09; 'values.': 0.09; 'what,': 0.09;
'that.': 0.15; 'data?': 0.16; 'else?': 0.16;
'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com':
0.16; 'mean,': 0.16; 'received:136.243': 0.16; 'received:172.58':
0.16; 'received:78.46': 0.16; 'received:www458.your-server.de':
0.16; 'received:your-server.de': 0.16; 'semantics': 0.16;
'situations.': 0.16; 'testers': 0.16; 'wrote:': 0.16; 'to:addr
:python-list': 0.20; 'code': 0.23; 'received:de': 0.23; 'suspect':
0.26; 'bit': 0.27; 'program': 0.31; 'empty': 0.32; 'python-list':
0.32; 'received:136': 0.32; 'unless': 0.32; 'but': 0.32; 'use,':
0.33; 'header:In-Reply-To:1': 0.34; 'item': 0.35; 'cases': 0.36;
'though': 0.37; 'file': 0.38; 'text': 0.39; 'use': 0.39; 'on.':
0.39; 'double': 0.40; 'something': 0.40; 'sorry': 0.60; "there's":
0.61; 'data,': 0.63; 'once': 0.63; 'down': 0.64; 'authors': 0.64;
'your': 0.64; 'look': 0.65; 'well': 0.65; 'acceptable': 0.69;
'losing': 0.69; 'piece': 0.69; 'carry': 0.71; 'little': 0.73;
'falls': 0.84; 'inputs': 0.84; 'maintain,': 0.84; 'modes': 0.84;
'sign,': 0.84
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=potatochowder.com; s=default2305; h=In-Reply-To:Content-Type:MIME-Version:
References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:
Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:
Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=Iiow9pdiq/OewlyDtdc2ef/QJXOcrvGu5DkAYGGpObY=; b=V7ZoxyRyEBVm6c0YhYWqxysk1z
6hZCtxGVZUv5wqr2l0EWRQoYfJcDesjaJhSAcPWbsEpeRQMUCiPi5DekAuJ/TIm78bto6kS6BtZkg
3lr3A3H6S5LGK1egkptdGj6hwJ7MxuMqwde6eG7n7bSp9IuOEhEEmsPuvgsyClSFDXpciagyH0dmZ
8cdyiFaalRZ7qeuHlvuEkNwbu6ynXpIbxlFhpqsQhevEsnKnGCwpL5PiSAlYWtRfTaRNz2PyKuK9O
ESrKq348ng0+qi4nVTcWKuZXH1rS/MIO0ka9tGGscQDKORXvoVayZMkPIKJaSvNkNvR80IjG1DX+l
EU4cKorg==;
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <6a691f90-3198-47c8-bb35-62a789280ae7@roelschroeven.net>
X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com
X-Virus-Scanned: Clear (ClamAV 0.103.10/27220/Wed Mar 20 09:25:13 2024)
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: <ZfqsOE67ohrmrzks@anomaly>
X-Mailman-Original-References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
<60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
<20240316230606.qjn5zepek645tsqq@hjp.at>
<98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
<20240317151153.cgnsvd6hd7pb767r@hjp.at>
<9206c6aa-0701-4d06-a5b9-29c79af215b0@DancesWithMice.info>
<mailman.113.1710709774.3452.python-list@python.org>
<Tl4KN.1884424$Ko1.841285@fx05.ams4>
<6a691f90-3198-47c8-bb35-62a789280ae7@roelschroeven.net>
 by: 2QdxY4RzWzUUiLuE@potatochowder.com - Wed, 20 Mar 2024 09:28 UTC

On 2024-03-20 at 09:49:54 +0100,
Roel Schroeven via Python-list <python-list@python.org> wrote:

> You haven't only checked for None! You have rejected *every* falsish value,
> even though they may very well be acceptable values.

OTOH, only you can answer these questions about your situations.

Every application, every item of configuration data, is going to be a
little bit different.

What, exactly, does "missing" mean? That there's no entry in a config
file? That there's some sort of degenerate entry with "missing"
semantics (e.g. a line in a text file that contains the name of the
value and an equals sign, but no value)? An empty string or list? Are
you making your program easier for users to use, easier for testers to
test, easier for authors to write and to maintain, or something else?
What is your program allowed and not allowed to do in the face of
"missing" configuration data?

Once you've nailed down the semantics of the configuration data, then
the code usually falls out pretty quickly. But arguing about corner
cases and failure modes without specifications is a losing battle.
Every piece of code is suspect unless you know what the inputs mean, and
what the application "should" do if the don't look like that.

Python's flexibiliry and expressiveness are double edge swords. Use
them wisely. :-)

Sorry for the rant.

Carry on.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor