#!/usr/bin/python import errno import os import sys names = [name for name in dir(errno) if name.startswith('E')] codes = dict((name, getattr(errno, name)) for name in names) texts = dict((name, os.strerror(codes[name])) for name in names) def report(name): print name, codes[name], texts[name] for arg in sys.argv[1:]: if arg in names: report(arg) else: for name, code in codes.iteritems(): if arg == str(code): report(name) break else: found = False for name, text in texts.iteritems(): if arg.lower() in text.lower(): report(name) found = True if not found: print 'Unknown:', arg