__or__ == |
Error:
>>> a={'a':1, }
>>> b = lambda x: x*2
>>> a | b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'dict' and 'function'
the first object must has "__or__" method
Right:
>>> class a(object):
... def __or__(self, t):
... return id(t)
...
>>> c = a()
>>> d = a()
>>> c|d
13041232
>>> id(c)
13041264
>>> id(d)
13041232
>>> c|""
12492856
Example: (Transformer)
No comments:
Post a Comment