bool and int

Python python at bladeshadow.org
Wed Jan 25 22:06:12 EST 2023


On Wed, Jan 25, 2023 at 01:01:24PM +1100, Chris Angelico wrote:
> On Wed, 25 Jan 2023 at 12:43, <avi.e.gross at gmail.com> 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 could still do things like I mention
> > above but only after consciously mapping your Boolean to an actual zero or
> > one of the kind wanted.
> 
> Python is strongly dynamically typed. You may be thinking of "static
> typing" rather than "strong typing" here,

You often insist on this but frankly it does not jibe with the
definitions of "strongly typed language" that I was taught or that I
still see used commonly, including in literature and on sites that aim
to teach people about computer science, which basically amount to:

1. A language whose variables are defined by type, and can only hold
   that type, typically but not necessarily compiled.
2. A language which strongly enforces restrictions on mixing or
   operating on, and/or implicitly converting different data types,
   with the implication that the structure of types is well-defined
   and rigid.

Python conforms to neither--its VARIABLES are normally untyped (though
the object data they hold obviously is).  Object instances can have
new fields added to them on the fly, willy-nilly, and Python allows
for any object which has an interface--or rather only the portion of
interface you care about in the moment--like the one it expects, to be
used in a given context, i.e. duck typing.  Useful properties (when
used carefully!) but not intuitively consistent with the idea of
"strong typing" and potentially dangerous if care is not taken.  When
YOU say that Python is strongly typed, you're using some other
definition--one that is perhaps technically correct, but seemingly
quite a lot of people in the field--including active students, college
professors, and seasoned professionsals--are unaware of...

The above usages are common and widespread, widely accepted--which is
inherently what makes word usages correct--and you very obviously know
full well what people mean when they use them; so "correcting" people
who use them seems rather unhelpful (certainly without detailing what
you think it means), inappropriate, and arguably just simply wrong.
It seems to serve no purpose other than to make communication harder,
and possibly to irritate people.  I would encourage you to consider
ceasing the practice, so as to not needlessly detract from the
otherwise usually good info you routinely provide...

And FWIW if you want some references, a google search will return
voluminous examples of people using the term as I described--from
acadamia to business--but here are just a few: 

https://www.cs.cornell.edu/courses/cs1130/2012sp/1130selfpaced/module1/module1part4/strongtyping.html
https://courses.yarrahills.vic.edu.au/moodle/mod/book/view.php?id=18778&chapterid=28
https://www.oreilly.com/library/view/mastering-c-and/9781785884375/ch02s02.html
https://www.postgresql.org/docs/current/typeconv-overview.html
https://www.sciencedirect.com/topics/computer-science/strongly-typed-language
https://www.techtarget.com/whatis/definition/strongly-typed



More information about the Python-list mailing list