[Python-ideas] String Subtraction

Mike Meyer mwm-keyword-python.b4bdba at mired.org
Fri Oct 15 00:13:26 CEST 2010

On Thu, 14 Oct 2010 23:49:25 +0200
Masklinn <masklinn at masklinn.net> wrote:

> On 2010-10-14, at 23:23 , Mike Meyer wrote:
> > 
> > The problem isn't that it's non-intuitive (there's only one intuitive
> > interface, and it's got nothing to do with computers), it's that there
> > are a wealth of "intuitive" meanings. A case can be made that it
> > should mean the same as any of these:
> Still, from my experience with numbers I would expect `a + b - b == a`, even if the order in which these operations are applied is important and not irrelevant.

Well, if you use the standard left-to right ordering, that equality
doesn't hold for the proposed meaning for string subtraction:

("xyzzy and " + "xyzzy") - "xyzzy" = " and xyzzy" != "xyzzy and "

It won't hold for any of the definition I proposed either - not if a
contains a copy of b.

Come to think of it, it doesn't hold for the computer representation
of numbers, either.

Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

More information about the Python-ideas mailing list