[kbperry wrote]
> In Python,
> When using the default except (like following)
> 
> try:
>     some code that might blow up
> 
> except:
>     print "some error message"


    >>> try:
    ...     1/0
    ... except:
    ...     import traceback
    ...     traceback.print_exc()
    ...
    Traceback (most recent call last):
      File "<stdin>", line 2, in ?
    ZeroDivisionError: integer division or modulo by zero


Or, if you are using the logging module:

    >>> import logging
    >>> log = logging.getLogger("myscript")
    >>> logging.basicConfig()
    >>>
    >>> try:
    ...     1/0
    ... except:
    ...     log.exception("whoa!")
    ...
    ERROR:myscript:whoa!
    Traceback (most recent call last):
      File "<stdin>", line 2, in ?
    ZeroDivisionError: integer division or modulo by zero


Cheers,
Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to