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

Antoon Pardon antoon.pardon at vub.be
Tue Feb 20 08:53:18 EST 2018


>>>> 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.

In C++ I can do something like:

  SomeClass MyVar;

And after that the kind of possible assignments to MyVar are constraint. It
makes the runtime throw an error when somewhere the program tries to assign
something to MyVar that isn't allowed by SomeClass.

You can't put such constraints on names in Python.

In C++ I can do some like:
    Some_Class: MyVar;

And after that, It will be impossible to assign a value to MyVar that
doesn't meet the
constraints imposed by the constructor/copy operator. You have put
somekind of
contract on the name MyVar, that limits the kind of things assignable to
it. You
can't put such constraints on a name in Python.
>
> Sigh. Languages are different. That's my point.

So, if languages are different, why the difficulty in accepting one can
do something the other can't?

>  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?

So you only want to see praisal for python? One can't express how one
prefers specific
features from other languages?





More information about the Python-list mailing list