Re: Configuring an object via a dictionary

Liste des GroupesRevenir à cl python 
Sujet : Re: Configuring an object via a dictionary
De : roel (at) *nospam* roelschroeven.net (Roel Schroeven)
Groupes : comp.lang.python
Date : 16. Mar 2024, 14:12:58
Autres entêtes
Message-ID : <mailman.102.1710591185.3452.python-list@python.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Barry via Python-list schreef op 16/03/2024 om 9:15:
>
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.
>
Me too. It's just too fragile. When writing code you're going to need an alternative for cases where "config.get('source_name') or default_value" doesn't work correctly; much better to use that alternative for all cases.
--
"This planet has - or rather had - a problem, which was this: most of the
people living on it were unhappy for pretty much of the time. Many solutions
were suggested for this problem, but most of these were largely concerned with
the movement of small green pieces of paper, which was odd because on the whole
it wasn't the small green pieces of paper that were unhappy."
         -- Douglas Adams

Date Sujet#  Auteur
16 Mar 24 o Re: Configuring an object via a dictionary1Roel Schroeven

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal