pattern matching in python
Quinn Dunkan
quinn at euro.ugcs.caltech.edu
Fri Jan 12 02:18:35 EST 2001
Every once in a while, I remember that python does basic tuple
pattern-matching, which doesn't seem to come up much in the documentation,
except for things like 'a, b = f()'. Specifically, nested matching, like:
t = [ (1, (2, 3), 4), ]
for (a, (x, y), b) in t: ...
I recently noticed, that, of course,
def f(a, (x, y), b): ...
works too. Is this standard, documented behaviour that can be relied on?
ok-so-where's-the-cons-operator-ly y'rs
More information about the Python-list
mailing list