Are the critiques in "All the things I hate about Python" valid?

Anders Wegge Keller wegge at wegge.dk
Sun Feb 18 06:55:59 EST 2018


På Sat, 17 Feb 2018 15:05:34 +1100
Ben Finney <ben+python at benfinney.id.au> skrev:
> boB Stepp <robertvstepp at 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.

-- 
//Wegge



More information about the Python-list mailing list