Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98272
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to handle exceptions properly in a pythonic way? |
| Date | Thu, 5 Nov 2015 14:58:33 +1100 |
| Lines | 18 |
| Message-ID | <mailman.43.1446695916.16136.python-list@python.org> (permalink) |
| References | <4b303213-62e2-42d4-b2f6-4fc1f6025944@googlegroups.com> <n18fmg$oj6$1@reader1.panix.com> <e134f1a3-89cc-4497-807e-3dd0836fb5e6@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de wj1IAGC3sRUL0HY4xsP64QvQfCmAMBLWpqoFWt3SzYTQ== |
| Return-Path | <rosuav@gmail.com> |
| 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; 'received:209.85.223': 0.03; 'value,': 0.03; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'block.': 0.09; 'incorrect': 0.09; 'indication': 0.09; 'exception': 0.13; 'thu,': 0.15; 'value.': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'prefer?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'try/except': 0.16; 'wrote:': 0.16; 'string,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In-Reply- To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'actual': 0.28; 'forces': 0.29; 'raising': 0.33; 'traceback': 0.33; 'received:google.com': 0.35; 'fail': 0.35; 'nov': 0.35; 'returning': 0.35; 'problem.': 0.35; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'means': 0.39; 'test': 0.39; 'sure': 0.39; 'further': 0.62; 'back': 0.62; 'better.': 0.66; 'treat': 0.72; 'special': 0.73; 'chrisa': 0.84; 'subject:handle': 0.84; 'to:none': 0.91; 'results,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=IzLJWNeAe7tMh4jtYzwkkFJ/c0Tw1oVjn49IAE3m2MQ=; b=epw4UBZmN4aQcAXueRR+H1AP1grDl5p76f8AWsaizBPTSnLc6vNWwPIJn8svgAb/F6 nLMCqHOmHSTXunmdTml7RIuYT746xc1GrMpxcjNfaVAwe2VBi2Z8Fl3TbXX5HxhpCy+J JUPNXG/rYX8Ua0/PG7xuoLDgsDzk03hC9S0udv8izPir6B8sXecv4v2LeKkCrOS0yVgV 5cV6p4xRhF+1Yg31VOw4RP3trKxrN5aaq5cs8j2py2FDdIpMOwVLkmPeAIEse9Eb3cWf QbBKgstDzbPoyJpDsgZkQLPXfhb+h8bzPMrabm4XIm9Q+1/m+CEw65ZZKHb9WdhPNaSi aS1w== |
| X-Received | by 10.107.34.149 with SMTP id i143mr6683250ioi.157.1446695913880; Wed, 04 Nov 2015 19:58:33 -0800 (PST) |
| In-Reply-To | <e134f1a3-89cc-4497-807e-3dd0836fb5e6@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:98272 |
Show key headers only | View raw
On Thu, Nov 5, 2015 at 2:41 PM, <zljubisic@gmail.com> wrote: > Raising an exception forces me to put every call of the get_html function in try/except block. > If I am returning a special value, than I can call get_html and then test the value. > > I am not sure which approach is better. Raising an exception means that if you fail to put it in a try/except, you get a traceback that walks you through the exact location of the problem. Returning a special value means that if you fail to test the value, you either get an exception further on (if you get back None and try to treat it as a string, for instance), or get incorrect results, with no indication of the actual cause of the problem. Which would you prefer? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-02 11:24 -0800
Re: How to handle exceptions properly in a pythonic way? John Gordon <gordon@panix.com> - 2015-11-02 20:05 +0000
Re: How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-04 19:41 -0800
Re: How to handle exceptions properly in a pythonic way? Chris Angelico <rosuav@gmail.com> - 2015-11-05 14:58 +1100
Re: How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-04 20:18 -0800
Re: How to handle exceptions properly in a pythonic way? Chris Angelico <rosuav@gmail.com> - 2015-11-05 15:51 +1100
Re: How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-09 13:43 -0800
Re: How to handle exceptions properly in a pythonic way? tian.su.yale@gmail.com - 2015-11-04 21:02 -0800
Re: How to handle exceptions properly in a pythonic way? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-02 13:58 -0700
Re: How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-04 20:11 -0800
Re: How to handle exceptions properly in a pythonic way? tian.su.yale@gmail.com - 2015-11-04 21:15 -0800
Re: How to handle exceptions properly in a pythonic way? zljubisic@gmail.com - 2015-11-09 13:36 -0800
csiph-web