Python dot-equals (syntax proposal)
Lie Ryan
lie.1296 at gmail.com
Sun May 2 03:09:36 EDT 2010
On 05/02/10 10:58, Steven D'Aprano wrote:
> On Sun, 02 May 2010 05:08:53 +1000, Lie Ryan wrote:
>
>> > On 05/01/10 11:16, Steven D'Aprano wrote:
>>> >> On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote:
>>> >>
>>> >> In practice though, I think that's a difference that makes no
>>> >> difference. It walks like an operator, it swims like an operator, and
>>> >> it quacks like an operator.
>>> >>
>>> >>
>> > Nope it's not. A full-time operator in python have a reflected version
>> > (e.g. __radd__), which dot does not have.
> What are the reflected versions of __eq__ and __ne__ (binary == and !=
> operators)?
Python do not have them now, but it does make sense if python have
them[1]. OTOH, given current python's language semantic, __rgetattr__
doesn't make any sense; adding __rgetattr__ would require a quite
fundamental change to the language's semantic, primarily how attribute
resolution works.
[1] though they'd probably be dismissed as bad idea since equality and
inequality are supposed to be a symmetric relation; reflected
(in)equality makes it way too easy to break that premise
> And __neg__, __pos__ and __inv__ (for the unary - + and ~ operators)?
>
> And the three-argument form of __pow__ for power(1, 2, x)?
I know you're a famed nitpicker, but don't be silly, reflected operator,
by definition, only makes sense for binary operator.
More information about the Python-list
mailing list