Path: csiph.com!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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'suppose': 0.07; 'try:': 0.07; 'macros': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'aug': 0.13; 'language': 0.14; 'integer.': 0.16; 'specified.': 0.16; 'subject:arithmetic': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'define': 0.20; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'looks': 0.26; 'guess': 0.27; "doesn't": 0.28; 'chris': 0.28; 'thursday,': 0.30; 'function': 0.30; 'could': 0.32; 'print': 0.32; 'point,': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'exist': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'except': 0.36; 'possible': 0.37; 'ok,': 0.37; 'passed': 0.37; 'skip:z 10': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'august': 0.66 Newsgroups: comp.lang.python Date: Thu, 23 Aug 2012 02:22:30 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=217.155.40.178; posting-account=-3s4ywoAAAAAaBnmwFd0aHQ7KiR90tL- References: <8b9a5844-66b0-4940-946a-5e626462cdce@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 217.155.40.178 MIME-Version: 1.0 Subject: Re: Guarding arithmetic From: Mark Carter To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345713754 news.xs4all.nl 6881 [2001:888:2000:d::a6]:46498 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27713 On Thursday, 23 August 2012 10:16:08 UTC+1, Chris Angelico wrote: > On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter <> wrote: > > Suppose I want to define a function "safe", which returns the argument passed if there is no error, and 42 if there is one. > only possible with floating point, not integer. > > try: > print 1/0 > except ZeroDivisionError: > print 42 OK, so it looks like a solution doesn't exist to the problem as specified. I guess it's something that only a language with macros could accommodate.