Created
July 21, 2014 17:50
-
-
Save mynameisfiber/848a4bd633083d36c370 to your computer and use it in GitHub Desktop.
SuperNone -- The most None a None type can get.
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
| from functools import total_ordering | |
| @total_ordering | |
| class SuperNone(object): | |
| # general properties / methods | |
| def __getattr__(self, *args, **kwargs): | |
| return self | |
| def __call__(self, *args, **kwargs): | |
| return self | |
| def __setattr__(self, *args, **kwargs): | |
| pass | |
| # sequence methods | |
| def __contains__(self, *args, **kwargs): | |
| return None | |
| # ordering | |
| def __lt__(self, *args, **kwargs): | |
| return True | |
| def __eq__(self, *args, **kwargs): | |
| return False | |
| # math | |
| def __add__(self, *args, **kwargs): | |
| return self | |
| def __sub__(self, *args, **kwargs): | |
| return self | |
| def __mul__(self, *args, **kwargs): | |
| return self | |
| def __div__(self, *args, **kwargs): | |
| return self | |
| # representations | |
| def __repr__(self): | |
| return "<SuperNone>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment