def option_default(self, opt, optdict=None): """return the default value for an option""" if optdict is None: optdict = self.get_option_def(opt) default = optdict.get('default') if callable(default): default = default() return default
def decorator(func): try: name = methodname or func.__name__ except AttributeError: raise AttributeError('%s has no __name__ attribute: ' 'you should provide an explicit `methodname`' % func) if callable(func) and sys.version_info < (3, 0): setattr(klass, name, method_type(func, None, klass)) else: # likely a property # this is quite borderline but usage already in the wild ... setattr(klass, name, func) return func
def decorator(func): try: name = methodname or func.__name__ except AttributeError: raise AttributeError( '%s has no __name__ attribute: ' 'you should provide an explicit `methodname`' % func) if callable(func) and sys.version_info < (3, 0): setattr(klass, name, method_type(func, None, klass)) else: # likely a property # this is quite borderline but usage already in the wild ... setattr(klass, name, func) return func