Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15786
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'sys': 0.05; 'exception:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'rolling': 0.09; 'valueerror:': 0.09; 'much!': 0.15; 'chris,': 0.16; 'except:': 0.16; 'frederic': 0.16; 'runtimeerror': 0.16; '>>>': 0.18; '(most': 0.21; 'header:In-Reply-To:1': 0.23; 'traceback': 0.24; 'raise': 0.27; 'framework': 0.28; 'import': 0.28; 'print': 0.29; 'subject:?': 0.31; 'thanks': 0.31; 'to:addr:python-list': 0.32; 'instead': 0.33; 'header:User-Agent:1': 0.33; 'header:X -Complaints-To:1': 0.33; 'test': 0.34; 'last):': 0.34; 'try:': 0.34; 'subject:How': 0.35; 'file': 0.36; 'help!': 0.37; 'using': 0.37; 'received:org': 0.37; 'except': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'skip:l 20': 0.40; 'your': 0.61; 'subject:. ': 0.65; 'message")': 0.84; 'schrieb': 0.84; 'subject:try': 0.84; 'traceback,': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Christian Heimes <lists@cheimes.de> |
| Subject | Re: try - except. How to identify errors unknown in advance? |
| Date | Wed, 16 Nov 2011 19:47:45 +0100 |
| References | <1321462647.2315.31.camel@hatchbox-one> <CALvWhxtY+gaC+xHx4qdakAMstFkOC8eUxRiV9tBGRO3Q46QqXw@mail.gmail.com> <1321468772.2315.35.camel@hatchbox-one> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | smtp.semantics.de |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
| In-Reply-To | <1321468772.2315.35.camel@hatchbox-one> |
| X-Enigmail-Version | 1.4a1pre |
| OpenPGP | id=AD16AB1B; url=http://cheimes.de/heimes.asc |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2780.1321469278.27778.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1321469278 news.xs4all.nl 6843 [2001:888:2000:d::a6]:34703 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:15786 |
Show key headers only | View raw
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: try - except. How to identify errors unknown in advance? Christian Heimes <lists@cheimes.de> - 2011-11-16 19:47 +0100
csiph-web