sequence multiplied by -1

MRAB python at mrabarnett.plus.com
Sat Oct 2 22:24:19 CEST 2010


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



More information about the Python-list mailing list