Skip to content

Instantly share code, notes, and snippets.

@mynameisfiber
Created July 21, 2014 17:50
Show Gist options
  • Select an option

  • Save mynameisfiber/848a4bd633083d36c370 to your computer and use it in GitHub Desktop.

Select an option

Save mynameisfiber/848a4bd633083d36c370 to your computer and use it in GitHub Desktop.
SuperNone -- The most None a None type can get.
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