pattern matching in python

Quinn Dunkan quinn at ngwee.ugcs.caltech.edu
Fri Jan 12 16:32:48 EST 2001


I was only looking for a cons operator as a way to suggest an extension to
python's pattern matching... i.e., something like:

1 ++ [2, 3] # -> [1, 2, 3]

Of course, since python lists are arrays, this doesn't make much sense, but
hey, then you could write:

def f(a, x ++ y, b): ...

Or maybe:

def f(a, [x, *y], b): ...

Then of course you could also do:

a, [x, y, *rest], b = 1, [2,3,4,5], 6



See, when some people find a little-used obscure dusty corner, they want to
board it up and paint over it, to make everything "pretty" and "clean".
Others feel a need to decorate it with random little trinkets and further
obscurities and call it home.



More information about the Python-list mailing list