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

Paul Moore p.f.moore at gmail.com
Tue Feb 20 08:12:31 EST 2018


On 20 February 2018 at 13:04, Antoon Pardon <antoon.pardon at vub.be> wrote:
> On 20-02-18 13:11, Paul Moore wrote:
>> On 20 February 2018 at 11:18, Antoon Pardon <antoon.pardon at vub.be> wrote:
>>> Personnally I would prefer the type system of Pascal and Modula2 with
>>> their interval type
>>> above a Digit class in python. For the simple reason that once you had
>>> declared a variable
>>> like this:
>>>     x: 1 .. 10;
>>>
>>> Each assignment to x would then implicitly do something like an assert
>>> to checks the constraint,
>>> so it would be impossible to ever assign 11 to x, without an error being
>>> thrown.
>>>
>>> There is no such possibility in Python. You can off course start with x
>>> = Digit(5), but the language
>>> won't stop you from doing x = 11 later.
>> All that is saying is that in Pascal, variables have types, whereas in
>> Python values have types but variables (names ;-)) don't. It's true,
>> but not particularly important in toy examples like this. In larger
>> scale programs, tracking the "type" of what gets assigned to a
>> variable can be really useful, and carefully managed types can help
>> with this. Pascal/Modula2 (and C/C++) have the compiler do this,
>> Python has a separate tool (MyPy).
>
> In Pascal and Modula2 type checking was not limited to compile time. Part
> of that type checking was done at by the runtime enviroment.

So? What point are you making? (I genuinely don't see - you surely
aren't saying that Python can't implement runtime checks, and this is
all related to your original comment that "There is no such
possibility in Python").

>>> I'm not proficient with C++, but IIUC, you could make a class in C++ and
>>> have the constructor and
>>> copy operator check for these kind of things. True it would be run-time
>>> checks but that would
>>> already be more than Python can give.
>> That (run-time checks) is exactly the same as Python gives.
>
> No it isn't exactly the same. Those runtime checks are implicit. They are like
> a contract made at declaration time, which make it impossible to assign something
> to the variable that doesn't meet the constraint without the program throwing an
> error.
>
> You can't do something like that in Python.

I *am* (reasonably) proficient in C++, and (other than the "values
have types rather than variables/names" point I already stated was a
difference in how the languages work) I don't see anything in what
you're describing as "things C++ can do" that Python can't.

Sigh. Languages are different. That's my point. What's yours? If it's
that Python is worse than (some other language) then so what? Probably
true in some cases, but what makes you think you'll get enthusiastic
approval for such a statement in a Python group?

Bored now.

Paul



More information about the Python-list mailing list