[Python-ideas] Why operators are useful

Richard Damon Richard at Damon-Family.org
Sat Mar 16 07:17:10 EDT 2019


On 3/16/19 4:39 AM, Greg Ewing wrote:
> Rémi Lapeyre wrote:
>> I think this omit a very important property of
>> mathematic equations thought, maths is a very strongly typed language
>> which can be a significant improvement for readability.
>
> Python is very strongly typed too, so I don't really see how
> maths is different.

'Strongly Typed Language' can have slightly different meaning to
different people. In Python, an object have a very definite type which
strongly defines what you can do with that object, while other languages
are less definitive in that aspect. But in Python, names are NOT that
strongly typed, as a name can be rebound to any sort of object with a
wide variety of types, compared to other languages where before using
(or at first use) a variable you need to declare the 'type' that will be
stored in it, and that type is all that it can hold.

Rémi, I believe, is assuming in their example that by defining the field
of mathematics being used, there is at least an implicit definition (if
not actually explicit as such a statement would typically be preceded by
definitions) definition of the types of the variables. This is part of
the rigors of the language of mathematics.  Python on the other hand,
while it allows providing a 'Type Hint' for the type of a variable,
doesn't demand such a thing, so when looking at a piece of code you
don't necessarily know the types of the objects being used (which can
also be a strength).

-- 
Richard Damon



More information about the Python-ideas mailing list