Deutsch   English   Français   Italiano  
<mailman.122.1710926915.3452.python-list@python.org>

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

Path: ...!weretis.net!feeder8.news.weretis.net!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>
Bytes: 6433

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.