sequence multiplied by -1

geremy condra debatem1 at gmail.com
Sat Oct 2 23:09:15 CEST 2010


On Sat, Oct 2, 2010 at 1:24 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 02/10/2010 20:50, Dennis Lee Bieber wrote:
>>
>> On 02 Oct 2010 04:38:16 GMT, Steven D'Aprano
>> <steve at REMOVE-THIS-cybersource.com.au>  declaimed the following in
>> gmane.comp.python.general:
>>
>>
>>> If so, then we haven't gained anything, and the only thing that would
>>> satisfy such people would be for every function name and operator to be
>>> unique -- something which is impossible in practice, even if it were
>>> desirable.
>>>
>>        Well... We could maybe borrow from REXX... and use              ||
>>      for
>> concatenation.
>>
>>        Of course, REXX has the minor idiosyncrasy that everything is a
>> string unless the context needs a numeric...
>>
>> -=-=-=-=--
>> C:\Documents and Settings\Dennis Lee Bieber>rexx
>> x = 3
>> y = "this"
>> z = "that"
>> say y z
>> say y x
>> say y || z
>> say y || x
>> ^Z
>> this that
>> this 3
>> thisthat
>> this3
>>
>> C:\Documents and Settings\Dennis Lee Bieber>
>> -=-=-=-=--
>
> How about "~", which is currently has only a unary form:
>
>>>> "foo" ~ "bar"
> 'foobar'
>>>> [1, 2, 3] ~ [4, 5, 6]
> [1, 2, 3, 4, 5, 6]
>
> Think of it as meaning "followed by".
>
> Actually, I wonder if it could also be used with generators to mean
> itertools.chain:
>
>>>> r1 = range(3)
>>>> r2 = range(3, 6)
>>>> for x in r1 ~ r2:
>        print(x)
>
>
> 0
> 1
> 2
> 3
> 4
> 5

I'd actually love the ability to overload this, although I'm not sold
on the itertools.chain thing. To me it looks a lot like the 'is
isomorphic' operator from graph theory, and we could really use that
in Graphine.

Geremy Condra



More information about the Python-list mailing list