sync from Atlas repo
This commit is contained in:
17
operator/dispatch.py
Normal file
17
operator/dispatch.py
Normal file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Experiments with infix operator dispatch
|
||||
|
||||
>>> kadd = KnowsAdd()
|
||||
>>> kadd + 1
|
||||
(<KnowsAdd object>, 1)
|
||||
>>> kadd * 1
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class KnowsAdd:
|
||||
def __add__(self, other):
|
||||
return self, other
|
||||
def __repr__(self):
|
||||
return '<{} object>'.format(type(self).__name__)
|
||||
|
||||
Reference in New Issue
Block a user