On 2/18/18 6:55 AM, Anders Wegge Keller wrote:
På Sat, 17 Feb 2018 15:05:34 +1100
Ben Finney <ben+pyt...@benfinney.id.au> skrev:
boB Stepp <robertvst...@gmail.com> writes:
He blithely conflates “weakly typed” (Python objects are not weakly, but
very strongly typed)
Python is more strongly typed than PHP, but that doesn't really say much.
However, compared to a language like C, there are big holes in the type
safety.
>>> alist = [1, 'two', ('three', four), 5*'#']
That list is not only weakly typed, but rather untyped. There are no
safeguards in the language, that enforce that all elements in a list or
other container are in fact of the same type. Before type annotations and
mypy, I could not enforce that other than at runtime.
So claiming Python to have very strongly typed objects is a bit of a
strecth. PHP that many of us like to be smug about is equally strongly
typed. It just comes with a metric ton of inane type coersions that have
gone too far. However, we are happy to add an integer to a float without
having to make an explicit conversion every time, so ... Thread carefull and
all that.
Note, that 'Only at Runtime' isn't a distinction between Weakly Typed or
Strongly Typed but between Statically Typed and Dynamically Typed.
Python is clearly dynamically typed, as we don't need to assign a type
to a symbol, and it will always reflect a value of that type,
Python is much stronger typed than PHP, because in PHP you can do things
like 1 + '2' and get 3, as string values will naturally convert
themselves to numbers, Python won't do this. Yes Python will freely
convert between numeric types, but I wouldn't say that Python claims to
be a language that focuses on numerics.
--
Richard Damon
--
https://mail.python.org/mailman/listinfo/python-list