A small inconsistency in syntax?

Michael Abbott michael.g.abbott at ntlworld.com
Thu Oct 25 22:26:42 CEST 2001

"Terry Reedy" <tjreedy at home.com> wrote in 
news:4vXB7.155961$5A3.54581770 at news1.rdc2.pa.home.com:

>>     time, status, _ = myobject.read()
>> instead, so I'm grumbling about trivia here.
> The problem is that Python assignment is not sufficiently well
> explained for many.  

Well, I guess I was thinking about assignment in terms of "pattern 
matching", where the right hand side is matched against the left hand side 
and assigments are used to fill in the gaps -- and an exception occurs if 
the pattern doesn't match.

However, Python tuple assignment does look somewhat like pattern matching; 
for example, sometimes my .read() method returns some (one) thing, and I 

    	time, status, ((value, boring),) = myobject.read()

So here I think of this as matching the one value (itself a pair of values) 
that happens to be returned.  This looks awfully like pattern matching (cf 

More information about the Python-list mailing list