Re: bool and int

2023-01-28 Thread Chris Angelico
On Sun, 29 Jan 2023 at 11:27, rbowman wrote: > > On Fri, 27 Jan 2023 21:35:11 -0800 (PST), Grant Edwards wrote: > > > In Unix shells, a return code of 0 is true and non-0 is false. > > That carries over to some C functions like strcmp() although it's more > complex. strcmp() returns the value of s

Re: RE: RE: bool and int

2023-01-28 Thread Dino
you have your reasons, and I was tempted to stop there, but... I have to pick this... On 1/26/2023 10:09 PM, avi.e.gr...@gmail.com wrote: You can often borrow ideas and code from an online search and hopefully cobble "a" solution together that works well enough. Of course it may suddenly f

Re: bool and int

2023-01-28 Thread rbowman
On Fri, 27 Jan 2023 21:35:11 -0800 (PST), Grant Edwards wrote: > In Unix shells, a return code of 0 is true and non-0 is false. That carries over to some C functions like strcmp() although it's more complex. strcmp() returns the value of subtracting the nth character of string b from string a i

Re: bool and int

2023-01-27 Thread Grant Edwards
On 2023-01-27, Mark Bourne wrote: > So Python is even flexible enough to be made to deal with insane > situations where False is 2! IIRC, in VMS DCL even numbers were false and odd numbers were true. In Unix shells, a return code of 0 is true and non-0 is false. Though that's not really the s

Re: bool and int

2023-01-27 Thread Chris Angelico
On Sat, 28 Jan 2023 at 11:45, Greg Ewing wrote: > > On 26/01/23 6:10 am, Chris Angelico wrote: > > And that's a consequence of a system wherein there is only one concept > > of "success", but many concepts of "failure". Whoever devised that > > system was clearly a pessimist :) > > Murphy's Law fo

Re: bool and int

2023-01-27 Thread Mark Bourne
avi.e.gr...@gmail.com wrote: ... Interestingly, I wonder if anyone has designed an alternate object type that can be used mostly in place of Booleans but which imposes changes and restrictions so trying to add a Boolean to an integer, or vice versa, results in an error. Python is flexible enough

Re: bool and int

2023-01-27 Thread Greg Ewing
On 26/01/23 6:10 am, Chris Angelico wrote: And that's a consequence of a system wherein there is only one concept of "success", but many concepts of "failure". Whoever devised that system was clearly a pessimist :) Murphy's Law for Unix: If something can go wrong, it will go wrong 255 times out

Re: bool and int

2023-01-27 Thread Rob Cliffe via Python-list
isinstance(b,int) True >>> That immediately tells you that either     bool is a subclass of int     int is a subclass of bool     bool and int are both subclasses of some other class In fact the first one is true. This is not a logical necessity, but the way Python happens to be designe

RE: RE: bool and int

2023-01-26 Thread avi.e.gross
ino Sent: Thursday, January 26, 2023 9:26 AM To: python-list@python.org Subject: Re: RE: bool and int Wow. That was quite a message and an interesting read. Tempted to go deep and say what I agree and what I disagree with, but there are two issues: 1) time 2) I will soon be at a disadvantage

Re: bool and int

2023-01-26 Thread Chris Angelico
On Fri, 27 Jan 2023 at 06:32, Dino wrote: > > On 1/25/2023 5:42 PM, Chris Angelico wrote: > > > > > Try this (or its equivalent) in as many languages as possible: > > > > x = (1 > 2) > > x == 0 > > > > You'll find that x (which has effectively been set to False, or its > > equivalent in any langua

Re: bool and int

2023-01-26 Thread Ben Bacarisse
Chris Angelico writes: > On Thu, 26 Jan 2023 at 08:19, Dino wrote: >> >> On 1/23/2023 11:22 PM, Dino wrote: >> > >>> b = True >> > >>> isinstance(b,bool) >> > True >> > >>> isinstance(b,int) >> > True >> > >>> >> >> ok, I read everything you guys wrote. Everyone's got their reasons >> obviou

Re: bool and int

2023-01-26 Thread 2QdxY4RzWzUUiLuE
On 2023-01-26 at 12:12:30 -0500, Dino wrote: > On 1/25/2023 5:42 PM, Chris Angelico wrote: > > > > > Try this (or its equivalent) in as many languages as possible: > > > > x = (1 > 2) > > x == 0 > > > > You'll find that x (which has effectively been set to False, or its > > equivalent in any

Re: bool and int

2023-01-26 Thread Dino
On 1/25/2023 5:42 PM, Chris Angelico wrote: Try this (or its equivalent) in as many languages as possible: x = (1 > 2) x == 0 You'll find that x (which has effectively been set to False, or its equivalent in any language) will be equal to zero in a very large number of languages. Thus, to an

Re: bool and int

2023-01-26 Thread Chris Angelico
On Fri, 27 Jan 2023 at 03:31, rbowman wrote: > > On Thu, 26 Jan 2023 04:10:30 +1100, Chris Angelico wrote: > > > > BASIC was like that too, although it (at least, the versions I used in > > my childhood) didn't have "True" and "False", you just got the actual > > values -1 and 0. They were the oth

Re: RE: bool and int

2023-01-26 Thread Dino
Wow. That was quite a message and an interesting read. Tempted to go deep and say what I agree and what I disagree with, but there are two issues: 1) time 2) I will soon be at a disadvantage discussing with people (you or others) who know more than me (which doesn't make them right necessari

Re: bool and int

2023-01-26 Thread rbowman
On Thu, 26 Jan 2023 04:10:30 +1100, Chris Angelico wrote: > BASIC was like that too, although it (at least, the versions I used in > my childhood) didn't have "True" and "False", you just got the actual > values -1 and 0. They were the other way around compared to what you're > saying here though

RE: bool and int

2023-01-26 Thread avi.e.gross
:52 AM To: python-list@python.org Subject: Re: bool and int I can't help but wonder if there exists some Java forum /mailing list going on about how horrible Python is. From: Python-list on behalf of rbowman Date: Wednesday, January 25, 2023 at 12:25 PM To: python-list@python.org Subjec

Re: bool and int

2023-01-26 Thread Chris Angelico
On Thu, 26 Jan 2023 at 21:53, Weatherby,Gerard wrote: > > I can’t help but wonder if there exists some Java forum /mailing list going > on about how horrible Python is. Try https://www.reddit.com/r/ProgrammerHumor/ for plenty of people whining about how horrible Python is. But along the way, yo

Flamebait (was: Re: bool and int)

2023-01-26 Thread 2QdxY4RzWzUUiLuE
On 2023-01-26 at 10:52:06 +, "Weatherby,Gerard" wrote: > I can’t help but wonder if there exists some Java forum /mailing list > going on about how horrible Python is. Not some of them. *All* of them. Here's the summary: - Dynamic Typing causes defects and makes non-toy software project

Re: bool and int

2023-01-26 Thread Weatherby,Gerard
I can’t help but wonder if there exists some Java forum /mailing list going on about how horrible Python is. From: Python-list on behalf of rbowman Date: Wednesday, January 25, 2023 at 12:25 PM To: python-list@python.org Subject: Re: bool and int *** Attention: This is an external email. Use

RE: bool and int

2023-01-25 Thread avi.e.gross
uage designed to minimize any ability to make many errors as the program refuses to run until highly polished? -Original Message- From: Python-list On Behalf Of Python Sent: Wednesday, January 25, 2023 10:06 PM To: python-list@python.org Subject: Re: bool and int On Wed, Jan 25, 2023 a

Re: bool and int

2023-01-25 Thread Python
On Wed, Jan 25, 2023 at 01:01:24PM +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 12:43, wrote: > > Python has a different philosophy than some other languages with strong > > typing. In some of those, you would not be allowed to add or multiply at > > random but would need to convert parts

RE: bool and int

2023-01-25 Thread avi.e.gross
-Original Message- From: Python-list On Behalf Of Chris Angelico Sent: Wednesday, January 25, 2023 5:43 PM To: python-list@python.org Subject: Re: bool and int On Thu, 26 Jan 2023 at 08:19, Dino wrote: > > On 1/23/2023 11:22 PM, Dino wrote: > > >>> b = True >

RE: bool and int

2023-01-25 Thread avi.e.gross
ed how this message got this long! Aaargh! -----Original Message- From: Python-list On Behalf Of Dino Sent: Wednesday, January 25, 2023 3:33 PM To: python-list@python.org Subject: Re: bool and int On 1/23/2023 11:22 PM, Dino wrote: > >>> b = True > >>> isinstance(

Re: bool and int

2023-01-25 Thread Chris Angelico
On Thu, 26 Jan 2023 at 08:19, Dino wrote: > > On 1/23/2023 11:22 PM, Dino wrote: > > >>> b = True > > >>> isinstance(b,bool) > > True > > >>> isinstance(b,int) > > True > > >>> > > ok, I read everything you guys wrote. Everyone's got their reasons > obviously, but allow me to observe that ther

Re: bool and int

2023-01-25 Thread Dino
On 1/23/2023 11:22 PM, Dino wrote: >>> b = True >>> isinstance(b,bool) True >>> isinstance(b,int) True >>> ok, I read everything you guys wrote. Everyone's got their reasons obviously, but allow me to observe that there's also something called "principle of least surprise". In my case,

Re: bool and int

2023-01-25 Thread Dennis Lee Bieber
On Tue, 24 Jan 2023 20:16:31 -0500, Mike Baskin declaimed the following: >Will all of you please stop sending me emails > Nobody is sending "you" emails deliberately (unless they have a poorly [to me] set up client that sends to the list AND the person who wrote the message they replied

Re: bool and int

2023-01-25 Thread rbowman
On Wed, 25 Jan 2023 06:53:44 -0500, 2QdxY4RzWzUUiLuE wrote: > They used Java at my last job (as in, the last job I had before I > retired), and it was absolutely awful, for any number of reasons, the > gymnastics (on many levels) required to support "primitive types" being > one of them. My firs

Re: bool and int

2023-01-25 Thread Chris Angelico
On Thu, 26 Jan 2023 at 03:19, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > Strongly disagree. There is PLENTY of practical value in using > > booleans as numbers. This is nothing to do with counting bytes, and > > everything to do with how useful it is in practice. > > IMO, the difference in rea

Re: bool and int

2023-01-25 Thread 2QdxY4RzWzUUiLuE
On 2023-01-25 at 23:11:37 +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 22:55, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > So, I think what you're trying to say is that you prefer the razor sharp > > quality of truthiness to the zen of explicit being better than implicit. > > Not su

Re: bool and int

2023-01-25 Thread Thomas Passin
On 1/25/2023 6:53 AM, 2qdxy4rzwzuui...@potatochowder.com wrote: They used Java at my last job (as in, the last job I had before I retired), and it was absolutely awful, for any number of reasons, the gymnastics (on many levels) required to support "primitive types" being one of them. In my one

Re: bool and int

2023-01-25 Thread Chris Angelico
On Wed, 25 Jan 2023 at 22:55, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2023-01-25 at 12:14:50 +1100, > Chris Angelico wrote: > > > On Wed, 25 Jan 2023 at 10:32, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > > > The usual complaint is that some people write FORTRAN no matter what > > >

Re: bool and int

2023-01-25 Thread 2QdxY4RzWzUUiLuE
On 2023-01-25 at 12:14:50 +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 10:32, <2qdxy4rzwzuui...@potatochowder.com> wrote: > > The usual complaint is that some people write FORTRAN no matter what > > language they're actually using. Are you writing Python in C#? ;-) > But the way I ha

Re: bool and int

2023-01-24 Thread rbowman
On Wed, 25 Jan 2023 12:14:50 +1100, Chris Angelico wrote: > So the problem isn't that I'm trying to write Python in C#, but that I'm > trying to write code that would work on pretty much *any other C-family > language*, but doesn't work on C#. I could use those techniques in > plenty of C-derived

Re: bool and int

2023-01-24 Thread Grant Edwards
On 2023-01-25, Mike Baskin via Python-list wrote: > Will all of you please stop sending me emails Oh dear. You might want to try unsubscribing from the list. Telling everybody to stop using the mailing list and newsgroup is a bit silly. -- Grant -- https://mail.python.org/mailman/listinfo/py

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 12:43, wrote: > Python has a different philosophy than some other languages with strong > typing. In some of those, you would not be allowed to add or multiply at > random but would need to convert parts of your calculation to all be the > same, such as a 32-bit integer. You

RE: bool and int

2023-01-24 Thread avi.e.gross
m Sent: Tuesday, January 24, 2023 6:31 PM To: python-list@python.org Subject: Re: bool and int On 2023-01-25 at 08:58:06 +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > > For backwards compatibility, bool was made a subclass of int. > > Plus, it&

Re: bool and int

2023-01-24 Thread David
On Wed, 25 Jan 2023 at 12:19, Mike Baskin via Python-list wrote: > Will all of you please stop sending me emails Hi. We don't have the power to do that. Because this is a public list, which works by people adding and removing themselves. You, or perhaps someone messing with you, added your email

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 12:20, Mike Baskin via Python-list wrote: > > Will all of you please stop sending me emails Learn to manage your own mailing list subscription. HINT: Look at the *ENTIRE* email, not just the bit up the top that makes you angry. > Sent from my iPhone Ahh, I see the problem

Re: bool and int

2023-01-24 Thread Mike Baskin via Python-list
Will all of you please stop sending me emails Sent from my iPhone > On Jan 24, 2023, at 2:59 PM, rbowman wrote: > > On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote: > >> $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) >> [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "lice

Re: bool and int

2023-01-24 Thread Chris Angelico
be very different, but it depends on the API. Could be: if "PreLaunch" in state: But the way I have to write it in C# is a messed-up version of C: if ((state & StartState.PreLaunch) > 0) { because bool and int are fundamentally different. Using the C style results in: Veloci

Re: bool and int

2023-01-24 Thread 2QdxY4RzWzUUiLuE
On 2023-01-25 at 08:58:06 +1100, Chris Angelico wrote: > On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > > For backwards compatibility, bool was made a subclass of int. > > Plus, it's really REALLY handy in quite a lot of situations. > > > > C# is pickier, which I guess is a good thing. > > > > N

Re: bool and int

2023-01-24 Thread Chris Angelico
On Wed, 25 Jan 2023 at 08:22, MRAB wrote: > For backwards compatibility, bool was made a subclass of int. Plus, it's really REALLY handy in quite a lot of situations. > > C# is pickier, which I guess is a good thing. > Nope, not a good thing. Actually a highly frustrating thing on those occasio

Re: bool and int

2023-01-24 Thread MRAB
On 2023-01-24 20:32, Weatherby,Gerard wrote: https://peps.python.org/pep-0285/ From: Python-list on behalf of rbowman Date: Tuesday, January 24, 2023 at 3:01 PM To: python-list@python.org Subject: Re: bool and int bool is a subtype of integer. I never dug that deep into Python's gut

Re: bool and int

2023-01-24 Thread Weatherby,Gerard
https://peps.python.org/pep-0285/ From: Python-list on behalf of rbowman Date: Tuesday, January 24, 2023 at 3:01 PM To: python-list@python.org Subject: Re: bool and int bool is a subtype of integer. I never dug that deep into Python's guts but I assume it goes back to boolean bei

Re: bool and int

2023-01-24 Thread Weatherby,Gerard
atamodel.html#the-standard-type-hierarchy From: Python-list on behalf of Dino Date: Tuesday, January 24, 2023 at 3:04 PM To: python-list@python.org Subject: bool and int *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** $ python P

bool and int

2023-01-24 Thread Dino
$ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> b = True >>> isinstance(b,bool) True >>> isinstance(b,int) True >>> WTF! -- https://mail.python.org/mailman/listinfo/python-list

Re: bool and int

2023-01-24 Thread rbowman
On Mon, 23 Jan 2023 23:22:00 -0500, Dino wrote: > $ python Python 3.8.10 (default, Mar 15 2022, 12:22:08) > [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" > for more information. > >>> b = True isinstance(b,bool) > True > >>> isinstance(b,int) > True > >>> > >>> > WTF!