On Jul 5, 2013 12:12 AM, "Lele Gaifax" <l...@metapensiero.it> wrote: > > Νίκος Gr33k <ni...@superhost.gr> writes: > > > try: > > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] > > except Exception as e: > > host = "Reverse DNS Failed" > > > > How can the above code not be able to reeverse dns any more and it > > falls back to the failed string? > > The only way to know is actually printing out the exception, either to > stderr, or better using the logging facility, as I suggested. > > FYI, your code above is (almost) exactly equivalent to the simpler > > try: > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] > except: > host = "Reverse DNS Failed" > > ciao, lele. >
They aren't equivalent. "except Exception" won't catch KeyboardInterrupt or SystemExit or a few others that you really don't want to catch in a generic error handler. You should almost never have a bare except.
-- http://mail.python.org/mailman/listinfo/python-list