Creating a calculator

alister alister.ware at ntlworld.com
Fri Jul 1 10:21:43 EDT 2016


On Fri, 01 Jul 2016 23:52:45 +1000, Steven D'Aprano wrote:

> On Fri, 1 Jul 2016 10:25 pm, Christopher Reimer wrote:
> 
>> 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.
> 
> I wish you wouldn't describe this as "crash".
> 
> The Python interpreter should never crash. That would be a segmentation
> fault, and that is considered to be a very serious bug.
> 
> But *raising an exception* is another story. Raising exceptions is not a
> crash, it is the interpreter working as expected. This statement:
> 
>     line_number, keyword, expr = "20 END".split(' ', 2)
> 
> is SUPPOSED to raise an exception, if it didn't, the interpreter would
> be broken. To call that a "crash" is horribly misleading.

i think this one is a matter of symantics
you are correct that the Python interpreter has not crashed but the op 
could also be considered correct is saying that HIS program has crashed.

As a child I had many programs "crash" in this way on my Commodore 64 
without killing the basic interpreter (at-least not until I started to 
include machine code ;-) ) 




-- 
Technology is dominated by those who manage what they do not understand.



More information about the Python-list mailing list