sequence multiplied by -1

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Oct 3 03:29:44 CEST 2010


On Sat, 02 Oct 2010 14:09:15 -0700, geremy condra wrote:

> I'd actually love the ability to overload this, although I'm not sold on
> the itertools.chain thing. To me it looks a lot like the 'is isomorphic'
> operator from graph theory, and we could really use that in Graphine.

You can overload the ~ operator, although only as a unary operator, not 
binary:

>>> class K:
...     def __invert__(self):
...             return "Inverted"
...
>>> ~K()
'Inverted'


-- 
Steven



More information about the Python-list mailing list