Created
March 4, 2010 03:57
-
-
Save leegao/321384 to your computer and use it in GitHub Desktop.
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
| #Hello World | |
| class Operator(object): | |
| def __init__(self, func, count=2): | |
| self._func_ = func | |
| self._args_ = [] | |
| self._count_ = count | |
| def __ror__(self, first_arg): | |
| self._args_.append(first_arg) | |
| return self | |
| def __or__(self, arg): | |
| self._args_.append(arg) | |
| if len(self._args_) >= self._count_: | |
| return self(*self._args_) | |
| else: | |
| raise RuntimeError("Incorrect number of parameters") | |
| def __call__(self, *args, **kwargs): | |
| self._args_ = [] | |
| return self._func_(*args, **kwargs) | |
| def alpha(letter): | |
| @Operator | |
| def _alpha(a,b): | |
| return a+letter+b | |
| return _alpha | |
| for c in range(65, 122): | |
| globals()[chr(c)] = alpha(chr(c)) | |
| print "H"|e|"l"|l|"o","W"|o|"r"|l|"d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment