Chris Angelico asked: what does a negative string look like?
This is a very good question. It looks a bit like a negative number.
>>> 2 + 2
4
>>> len('aa' + 'bb')
4
>>> len(-'bb')
-2 # Odd, I must confess.
>>> 5 + (-1)
4
>>> len('hello')
5
>>> len(-'o')
-1
>>> 'hello' + (-'o')
'hell'
>>> len('hello' + (-'o'))
4
Grade school: How can I possible have -3 apples in my bag.
University: How can I possibly be overdrawn in my bank account.
Negative strings are similar to negative numbers except:
For numbers a + b == b + a
For strings a + b != b + a
It is the non-commuting that make negative strings difficult. This is a bit
like computer programming. It's not enough to have the correct lines of
code (or notes). They also have to be put in the right order.
I hope this helps. I do this sort of math all the time, and enjoy it. Your
experience may be different.
--
Jonathan
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/