Created
February 28, 2019 20:52
-
-
Save feymartynov/c25f264f9f223fcb0d9d0d326a756fd6 to your computer and use it in GitHub Desktop.
cat operator in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Infix: | |
def __init__(self, function): | |
self.function = function | |
def __rxor__(self, other): | |
return Infix(lambda x, self=self, other=other: self.function(other, x)) | |
def __xor__(self, other): | |
return self.function(other) | |
def __call__(self, value1, value2): | |
return self.function(value1, value2) | |
_=Infix(lambda x, y: x * y) | |
print 2 ^_^ 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment