A small inconsistency in syntax?

Terry Reedy tjreedy at home.com
Fri Oct 26 02:56:35 CEST 2001

"Michael Abbott" <michael.g.abbott at ntlworld.com> wrote in message
news:Xns9145D94516673michaelrcpcouk at
> However, Python tuple assignment does look somewhat like pattern
> for example, sometimes my .read() method returns some (one) thing,
and I
> write:
>     time, status, ((value, boring),) = myobject.read()
> So here I think of this as matching the one value (itself a pair of
> that happens to be returned.  This looks awfully like pattern
matching (cf
> Haskell).

An so it is.  If the patterns do not match, an exception is raised.
However, after the match, the names (in your example above) 'time',
'status', 'value', and 'boring' are then bound to the corresponding
objects in the current namespace.

Terry J. Reedy

More information about the Python-list mailing list