Problems using struct pack/unpack in files, and reading them.

Steven D'Aprano steve at pearwood.info
Sat Nov 14 20:14:45 EST 2015


On Sun, 15 Nov 2015 09:53 am, Random832 wrote:

> Marko Rauhamaa <marko at pacujo.net> writes:
>> Actually, the real question is, is the unary - *really* so useful that
>> it merits existence or is it just something that was mindlessly copied
>> into programming languages from elementary school arithmetics?
> 
> The alternative, if you want to be able to specify negative numbers at
> all, is to put - in the literal syntax. So what's "x-1"?
> 
> I suppose you could use some *different* symbol in the literal syntax
> for negative numbers. I had a calculator once that used a different
> symbol (looked like a small superscript minus sign) for it. But Python
> is limited to ASCII for basic syntax elements for good reasons.

I have a textbook for Pascal programming which includes a project to write
an "arithmetic evaluator". It uses ~ for unary minus and - for binary
subtraction, and doesn't include unary plus. The reason was to simplify the
parser, so that every symbol had exactly one meaning.

So in an alternate universe where Guido was less influenced by C, or where
he wasn't as good as writing parsers as the real GvR is, we may have ended
up with ~ for unary minus and no unary plus.



-- 
Steven




More information about the Python-list mailing list