Skip to content

Instantly share code, notes, and snippets.

@textbook
Last active November 20, 2016 09:32
Show Gist options
  • Save textbook/8605b73c1dda33a36cc8a526bbd0223f to your computer and use it in GitHub Desktop.
Save textbook/8605b73c1dda33a36cc8a526bbd0223f to your computer and use it in GitHub Desktop.
Non-data descriptors as applied to http://stackoverflow.com/q/40695883/3001761
VERB_QUIET = 0
class VerbosityLevel(object):
def __init__(self, level):
self.level = level
def __get__(self, obj, _):
return obj.level >= self.level
class Verbosity(object):
"""Class used to determine what to print to standard output.
Attributes:
level: Determines what level of output to print.
"""
def __init__(self, level=VERB_QUIET):
self.level = level
quiet = VerbosityLevel(VERB_QUIET)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment