On Sun, Nov 15, 2015 at 2:43 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano <st...@pearwood.info> wrote: >> Python has operator overloading, so it can be anything you want it to be. >> E.g. you might have a DSL where +feature turns something on and -feature >> turns it off. > > By that argument we should also have operators ~, !, $, \, ? because > some hypothetical DSL might someday want to use them for something.
Unary tilde does, doing bitwise negation on integers. Backslash probably never will, due to confusion with line continuation and stuff. But let's look at the parallel-universe Python in which unary plus never existed (but unary minus did). The PEP preamble for its inclusion says: Abstract This PEP proposes a new unary version of the binary + operator. Specification A new unary operator is added to the Python language: ======= ========================= =========== Op Precedence/associativity Method ======= ========================= =========== ``+`` Same as unary ``-`` ``__pos__`` ======= ========================= =========== No implementations of this methods is added to the builtin or standard library types. However, we foresee that Domain-Specific Languages can make use of this parallel to unary minus; see Intended usage details below for details. Okay. I've done my bit, stealing text from PEP 465. Now Steven, you can write the Motivation section. There's a lot of similarities here (Python's built-in types do not need @ or unary + for anything), but the big push for 465 was that there have been calls for the new operator for years. So... where would the "please add unary plus" calls come from? ChrisA -- https://mail.python.org/mailman/listinfo/python-list