def warning():
def _warnformat(msg, category, filename, lineno, file=None, line=None):
return '%s:%s: %s: %s\n' % (filename, lineno, category.__name__, msg)
default_warn_format = warnings.formatwarning
try:
warnings.formatwarning = _warnformat
yield warnings.warn
finally:
warnings.formatwarning = default_warn_format
# Descriptor protocol for creating an attribute that is bound to an
# (arbitrarily nested) attribute accessible to the instance at runtime.
评论列表
文章目录