[Python-ideas] Why operators are useful

Rémi Lapeyre remi.lapeyre at henki.fr
Mon Mar 18 08:51:08 EDT 2019

Le 17 mars 2019 à 02:01:51, Greg Ewing
(greg.ewing at canterbury.ac.nz(mailto:greg.ewing at canterbury.ac.nz)) a

> Richard Damon wrote:
> > 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.
> In Python, we have such implicit definitions in the form
> of comments, and inferences from the way things are used.

Yes, exactly. You can make "inferences from the way things are used". But the
comparison with maths stops here, you don’t make such inferences because your
object must be well defined before you start using it. You can track types with
comments but you need to comment each line. There is also no definitions if no
comment was written.

In maths, an given object is not duck because it quacks and walks like
a duck, it’s
either part of the set of all ducks, or not.

Python’s typing is implicit
Maths’ typing is explicit so you don’t need to spend brain cycles to
determine them.

Python is imperative
Maths is functional

So once you know the type or the value of an object in maths, you
don’t have to check
all the time to make sure they did not change and spend precious brain
cycles tracking it.

I would argue that those two differences are really important when
using an operator,
When doing maths, you are always acutely aware of the context.

> > when looking at a piece of code you
> > don't necessarily know the types of the objects being used
> And if you look at an equation from a mathematics text without
> the context in which it appears, you won't always know what
> it means either.

But the equation is only meaningful in a given context. Asking whether
f: x -> 1/x
is differentiable is only meaningful if we know whether x is in R, C,
[1; +oo[...

> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list