Why does
1.__add__(1)
yield SyntaxError: invalid syntax? What do the extra brackets add?
(1).__add__(1)
                This is an effect of the tokenizer:  1.__add__(1) is split into the tokens "1.", "__add__", "(", "1", and  ")", since the tokenizer always tries to built the longest possible token.  The first token is a floating point number, directly followed by an identifier, which is meaningless to the parser, so it throws a SyntaxError.
Simply adding a space before the dot will make this work:
>>> 1 .__add__(1)
2
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With