RE: Configuring an object via a dictionary

Liste des GroupesRevenir à cl python 
Sujet : RE: Configuring an object via a dictionary
De : <avi.e.gross (at) *nospam* gmail.com>
Groupes : comp.lang.python
Date : 16. Mar 2024, 03:06:31
Autres entêtes
Message-ID : <mailman.100.1710551196.3452.python-list@python.org>
References : 1 2 3 4 5 6
User-Agent : Microsoft Outlook 16.0
A part of the Python view of the world is about a concept of whether
something is "truthy" or not and thus many corners of the language do not
care what kind of object an expression returns. If the object is returned in
a context looking for not a Boolean value but a truth value, it is evaluated
and in other scenarios, left alone to propagate in the code.

Changing such behavior would be a very serious undertaking, and frankly,
silly.

But if anyone really wants an actual Boolean, then the non-not operator
should do the trick as !(whatever) takes what follows as a truthy value and
negates it and a second ! brings it back as a True/False as in !!(whatever)

And for many data types, perhaps all, you can use the bool() function that I
believe follows the same rules about being truthy.

Both of the above should be fairly easy to use in any rare contexts that
demand a more standard Boolean result as in some other languages.

It is one of many strengths of python that supports varieties of
polymorphism. And it allows a value to be passed or returned that can both
be viewed as some kind of object of many kinds and seen as a Boolean for
considerations like flow of control.

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On
Behalf Of Dan Sommers via Python-list
Sent: Friday, March 15, 2024 5:33 PM
To: python-list@python.org
Subject: Re: Configuring an object via a dictionary

On 2024-03-15 at 15:48:17 -0400,
Thomas Passin via Python-list <python-list@python.org> wrote:

[...] And I suppose there is always the possibility that sometime in
the future an "or" clause like that will be changed to return a
Boolean, which one would expect anyway.

Not only is the current value is way more useful, but changing it would
be a compatibility and maintenance nightmare.

If I want Java, I know where to find it.  :-)
--
https://mail.python.org/mailman/listinfo/python-list


Date Sujet#  Auteur
15 Mar 24 * Configuring an object via a dictionary15Loris Bennett
15 Mar 24 +- Re: Configuring an object via a dictionary1Mats Wichmann
15 Mar 24 +- Re: Configuring an object via a dictionary1Thomas Passin
15 Mar 24 +* Re: Configuring an object via a dictionary4Tobiah
15 Mar 24 i`* Re: Configuring an object via a dictionary3Tobiah
18 Mar 24 i `* Re: Configuring an object via a dictionary2Loris Bennett
19 Mar 24 i  `- Re: Configuring an object via a dictionary1Pokemon Chw
15 Mar 24 +- Re: Configuring an object via a dictionary1Grant Edwards
15 Mar 24 +- Re: Configuring an object via a dictionary1Thomas Passin
15 Mar 24 +- Re: Configuring an object via a dictionary (Posting On Python-List Prohibited)1Lawrence D'Oliveiro
15 Mar 24 +- Re: Configuring an object via a dictionary12QdxY4RzWzUUiLuE
16 Mar 24 +- Re: Configuring an object via a dictionary1dn
16 Mar 24 +- Re: Configuring an object via a dictionary1Thomas Passin
16 Mar 24 +- Re: Configuring an object via a dictionary1<avi.e.gross
18 Mar 24 `- Re: Configuring an object via a dictionary1Anders Munch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal