On 2013-10-16 06:09, Chris Angelico wrote: > > "xyz" - "abc"; > (1) Result: "xyz" > > "cba" - "abc"; > (2) Result: "cba" > > "abcdabc" - "abc"; > (3) Result: "d" > > Every instance of the subtracted-out string is removed. It's > something like x.remove(y) in many other languages.
Or as one might write x.remove(y) in Python: for demo in ("xyz", "cba", "abcdabc"): print repr(demo), "->", repr(demo.replace("abc", "")) > >>> "abc"-"b"; > >> (2) Result: "ac" > >>> "foo bar asdf qwer"/" "*"##"; > >> (3) Result: "foo##bar##asdf##qwer" > > > > And what, pray tell, would "foo bar" / " " be on its own? > > A two-element array "foo","bar": > > > "foo bar" / " "; > (4) Result: ({ /* 2 elements */ > "foo", > "bar" > }) which in Python sounds suspiciously like dividend.split(divisor) So Python's giving both functionalities in ways that are more readable (and in the case of "-", more flexible, as you can replace with anything, not just delete the matching content). While subtraction and division of strings make theoretical sense, I'm glad I don't have to think about them in my Python code ;-) -tkc -- https://mail.python.org/mailman/listinfo/python-list