Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15786 > unrolled thread
| Started by | Christian Heimes <lists@cheimes.de> |
|---|---|
| First post | 2011-11-16 19:47 +0100 |
| Last post | 2011-11-16 19:47 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: try - except. How to identify errors unknown in advance? Christian Heimes <lists@cheimes.de> - 2011-11-16 19:47 +0100
| From | Christian Heimes <lists@cheimes.de> |
|---|---|
| Date | 2011-11-16 19:47 +0100 |
| Subject | Re: try - except. How to identify errors unknown in advance? |
| Message-ID | <mailman.2780.1321469278.27778.python-list@python.org> |
Am 16.11.2011 19:39, schrieb Frederic Rentsch:
>> py>import sys
>> py>try:
>> py> raise RuntimeError
>> py> except:
>> py> print sys.exc_info()
>> py>
>> (<type 'exceptions.RuntimeError'>, RuntimeError(), <traceback object
>> at 0x0000000002371588>)
>
> Chris, Thanks very much! Great help!
How about using the excellent logging framework instead of rolling your
own stuff? It can print the traceback, too.
>>> import logging
>>> logging.basicConfig()
>>> log = logging.getLogger("mymodule")
>>> try:
... raise ValueError("test")
... except Exception:
... log.exception("some message")
...
ERROR:mymodule:some message
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ValueError: test
Christian
Back to top | Article view | comp.lang.python
csiph-web