COMMAND = os.path.splitext(os.path.basename(sys.argv)) logging.debug('COMMAND: %s', COMMAND) DOCTESTDEBUG = logging.debug if COMMAND == 'doctest' else lambda *x: None
that lambda x: None construct simply creates a no-op that accepts any number of args. now I can sprinkle DOCTESTDEBUG('array is: %s', listing) statements in my routines and know they'll only be executed during doctests. neat, huh?
Back to blog or home page
last updated 2017-01-23 14:28:22. served from tektonic