[Python-ideas] PEP 428 - object-oriented filesystem paths
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Oct 6 02:54:21 CEST 2012
Andrew McNabb wrote:
> This is the difference between C++ style operators, where the only thing
> that matters is what the operator symbol looks like, and Python style
> operators, where an operator symbol is just syntactic sugar. In Python,
> the "/" is synonymous with `operator.div` and is defined in terms of the
> `__div__` special method. This distinction is why I hate operator
> overloading in C++ but like it in Python.
Not sure what you're saying here -- in both languages, operators
are no more than syntactic sugar for dispatching to an appropriate
method or function. Python just avoids introducing a special syntax
for spelling the name of the operator, which is nice, but it's
not a huge difference.
The same issues of what you *should* use operators for arises in
both communities, and it seems to be very much a matter of
personal taste.
(The use of << for output in C++ has never bothered me, BTW. There
are plenty of problems with the way I/O is done in C++, but the
use of << is the least of them, IMO...)
--
Greg
More information about the Python-ideas
mailing list