Creating a calculator

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Fri Jul 1 13:44:26 EDT 2016


Steven D'Aprano writes:

> 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 Christopher merely echoed my use of the word, so let me take the
blame.

But it's quite different to say "my program crashed" (didn't handle an
exception - fix program, or fix the input) and "the Python interpreter
crashed" (uh oh).



More information about the Python-list mailing list