Skip to content

Instantly share code, notes, and snippets.

@textbook
Last active Nov 20, 2016
Embed
What would you like to do?
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