[Python-ideas] PEP 428 - object-oriented filesystem paths
steve at pearwood.info
Mon Oct 8 15:03:55 CEST 2012
On 07/10/12 08:45, Andrew McNabb wrote:
> To clarify my point: in Python, "/" is not just a symbol--it
> specifically means "div".
I think that's wrong. / is a symbol that means whatever the class
gives it. It isn't like __init__ or __call__ that have defined
language semantics, and there is no rule that says that / means
division. I'll grant you that it's a strong convention, but it is
just a convention.
> Overriding the div operator requires creating a "__div__" special
Actually it is __truediv__ in Python 3. __div__ no longer has any
meaning or special status.
But it's just a name. __add__ doesn't necessarily perform addition,
__sub__ doesn't necessarily perform subtraction, and __or__ doesn't
necessarily have anything to do with either bitwise or boolean OR.
Why should we insist that __*div__ (true, floor or just plain div)
must only be used for numeric division when we don't privilege other
numeric operators like that?
More information about the Python-ideas