Re: Configuring an object via a dictionary

Liste des GroupesRevenir à cl python 
Sujet : Re: Configuring an object via a dictionary
De : 2QdxY4RzWzUUiLuE (at) *nospam* potatochowder.com
Groupes : comp.lang.python
Date : 20. Mar 2024, 11:28:24
Autres entêtes
Message-ID : <mailman.122.1710926915.3452.python-list@python.org>
References : 1 2 3 4 5 6 7 8 9 10
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.

Date Sujet#  Auteur
17 Mar 24 * Re: Configuring an object via a dictionary3dn
20 Mar 24 +- Re: Configuring an object via a dictionary1Roel Schroeven
20 Mar 24 `- Re: Configuring an object via a dictionary12QdxY4RzWzUUiLuE

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal