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

Alain Ketterlin alain at universite-de-strasbourg.fr.invalid
Mon Feb 19 05:04:47 EST 2018


Chris Angelico <rosuav at gmail.com> writes:

> On Mon, Feb 19, 2018 at 7:40 PM, Alain Ketterlin
> <alain at universite-de-strasbourg.fr.invalid> wrote:

>> No. C has much stronger rules, not on casting, but on accessing the
>> pointees, which basically invalidates your argument. Refer to the C
>> standard for details.
>
> Really? What rules?

Look at the C11 standard, section 6.3.2.3 ("Pointers"), 6.5.§6-7
("effective types"), and 6.5.3.2 ("Address and indirection operators").
It is tiring to constantly correct misunderstandings about pointer
casting and dereferencing.

> $ cat demo.c; gcc -Wall demo.c; ./a.out
[...]

If you don't know what undefined behavior is, better avoid C. Your
program has UB, anything can happen, including a seemingly sensible
result.

>> But you can modify the class (not __class__) in whatever way you want.
>> For instance:
>>
>>     class X(object):
>>         def f(self): ...
>>     ...
>>     del X.f
>>
>> So, in Python, knowing that object x is an instance of class X tells
>> you... essentially nothing. Call this strong typing if you want. In
>> terms of type systems, it is (strong) simplistic-typing based on type
>> labels, and labels carry no information whatsoever.
>
> Sure you can. And you can do a lot of other things at run time, too.
> Monkey-patching doesn't change the fact that x really and truly is an
> instance of class X, it just changes what you can do with that object.
> So what you're saying is that Python's dynamism makes it possible to
> disrupt duck typing. Sure, I'll grant you that. But the type system
> itself isn't broken by that.

I didn't say it is broken. I said: it does very little.

-- Alain.



More information about the Python-list mailing list