proposed language change to int/int==float (was: PEP0238 lament)
Terry Reedy
tjreedy at home.com
Tue Jul 24 14:01:27 EDT 2001
"Steve Horne" <sh at ttsoftware.co.uk> wrote in message
news:su3rltc8d88jrjdv9v73otlbsrajleqs21 at 4ax.com...
> > <list>*<list> raises a TypeError
>
> Given that other arithmetic operations have been hijacked for other
> jobs (concat etc) with lists, there *is* no sensible meaning for
this.
Actually there *is*: cross concatenation, (somewhat similar to set
cross products)
L1*L2 := [i1+i2 for i1 in Li for i2 in L2]
This is very handy for succinctly expressing many list-producing
functions and their corresponding algorithms. Example: combinations,
n things, k at a time
C(n,0) = ()
C(n,k>0) = [(n,)]*C(n-1,k-1) + C(n-1,k)
I have thought of submitting a PEP, after working out more details,
proposing this as a sequence operation that would make Python even
more like executable pseudocode.
Terry J. Reedy
More information about the Python-list
mailing list