Sujet : RE: Configuring an object via a dictionary
De : <avi.e.gross (at) *nospam* gmail.com>
Groupes : comp.lang.pythonDate : 16. Mar 2024, 02: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.orgSubject: 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