How can I overload the unary negative (minus) operator in Python?

Viewed 13142
class Card():
    def __init__(self, val):
        self.val = val

c = Card(1)
d = -c

I expect d to be a Card object and d.val to be -1. How I can do that?

1 Answers
Related