Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Reimer Newsgroups: comp.lang.python Subject: Re: Creating a calculator Date: Fri, 01 Jul 2016 07:15:19 -0700 Lines: 32 Message-ID: References: <0E77E5BC-E8CC-4951-B520-37BF2E596D3A@icloud.com> <577675ae$0$1604$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de TAqmdGq/CSWgP7Moz5Q4/Q+McRkZ9+OITtG/7U9AURGw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; 'bug.': 0.07; 'elegant': 0.07; 'cc:addr:python-list': 0.09; 'block.': 0.09; 'broken.': 0.09; 'exception,': 0.09; 'expected.': 0.09; 'interpreter,': 0.09; 'unpack': 0.09; 'python': 0.10; 'ignore': 0.14; 'interpreter': 0.15; '2016': 0.16; '6:52': 0.16; 'crashed': 0.16; 'crashes': 0.16; "didn't,": 0.16; 'expr': 0.16; 'keyword,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'try/except': 0.16; 'wrote:': 0.16; 'later': 0.16; "wouldn't": 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'prevent': 0.20; 'exceptions': 0.22; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'wrote': 0.23; 'split': 0.23; "doesn't": 0.26; 'chris': 0.26; 'fri,': 0.27; 'received:17': 0.27; 'raise': 0.29; 'code': 0.30; 'supposed': 0.31; 'another': 0.32; 'run': 0.33; "d'aprano": 0.33; 'raising': 0.33; 'steven': 0.33; 'but': 0.36; 'should': 0.36; 'needed': 0.36; 'basic': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'test': 0.39; 'where': 0.40; 'header:MIME-version:1': 0.60; 'wish': 0.71; 'jul': 0.72; 'header :In-reply-to:1': 0.84; 'story.': 0.96; 'serious': 0.97 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-07-01_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1607010143 X-Mailer: iPhone Mail (13F69) In-reply-to: <577675ae$0$1604$c3e8da3$5496439d@news.astraweb.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1467382521; bh=33wa1uC3h1GkTNmuqeyXQiKz2iUiZuGfT8kxhG/im8Q=; h=Content-type:MIME-version:Subject:From:Date:Message-id:To; b=mrsDKrs8Yqqkcy5dE8RoGCaewa77JT6lnanuDUqVboGIzfPCeI4ssaNMCrS7DCqPN 0nijelnicapcTVP4yr0I9ksF+fUJzAWSYbhbauFzIQ5NWuCHSSjGPSeJFJF7BilJHR crArFhV2jYWo0PQ+81pipiQ0Td5ON4F/2coQfoX5NvXGMpnWjDi8hXGmm4+8FR6bLe 3IukCwdao3bMhTjNaYYmg3C6jQU8F2TGwAUBsRbVhEi3QE42vxoNqLu2xOpvSPIGeo twSEEf/GEhCbdXGzrm1CseMDFRhm1iQAgHL0NkhpAdf4wHZ17SFaVVhVcy60jF0D/C MknSSkMl5YRpQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <0E77E5BC-E8CC-4951-B520-37BF2E596D3A@icloud.com> <577675ae$0$1604$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:110905 > On Jul 1, 2016, at 6:52 AM, Steven D'Aprano wrote: >=20 >> On Fri, 1 Jul 2016 10:25 pm, Christopher Reimer wrote: >>=20 >> For my BASIC interpreter, each line of BASIC is broken this way into >> tokens. > [...] >> By using * to unpack the split line, my program no longer crashes and no >> try/except block is needed to work around the crash. A later line of code= >> will test the expression, ignore if empty or run regex if full. >=20 > I wish you wouldn't describe this as "crash". >=20 > The Python interpreter should never crash. That would be a segmentation > fault, and that is considered to be a very serious bug. >=20 > But *raising an exception* is another story. Raising exceptions is not a > crash, it is the interpreter working as expected. This statement: >=20 > line_number, keyword, expr =3D "20 END".split(' ', 2) >=20 > is SUPPOSED to raise an exception, if it didn't, the interpreter would be > broken. To call that a "crash" is horribly misleading. Where did I write that the Python interpreter had "crashed"? I wrote that *my program* crashed and I found an elegant solution to prevent= the crashing from happening in the first place that doesn't require a try/e= xcept block. Chris R.=