On 2018-02-18 11:55, 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.

That's not untyped. If you want to see what untyped is, look at BCPL, which has only the "bit-pattern".

In an untyped language, operators and functions take values (bit-patterns) and return values, so there would be one operator for integer addition and another operator for floating-point addition. If you do integer addition on a value that represents a floating-point number, it won't complain, but the result will be meaningless. Similarly, it won't complain if you use a floating-point number, consisting of a mantissa and exponent, as a pointer.

  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.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to