[Python-ideas] New explicit methods to trim strings
tjreedy at udel.edu
Mon Mar 25 13:35:55 EDT 2019
On 3/25/2019 6:22 AM, Jonathan Fine wrote:
> Instead of naming these operations, we could use '+' and '-', with
> # Set the values of the variables.
> >>> a = 'hello '
> >>> b = 'world'
> >>> c = 'hello world'
> # Some values between the variables.
> >>> a + b == c
> >>> a == c - b
> >>> b = -a + c
Summary: using '-' for trimming works well for postfixes, badly for
prefixes, and not at all for infixes. Clever but not too practical
since trimming prefixes seems to be more common than trimming postfixes.
Terry Jan Reedy
More information about the Python-ideas