Multiple tuples for one for statement

Ivan Van Laningham ivanlan at pauahtun.org
Mon Apr 25 12:22:56 EDT 2005


Hi All--

Peter Hansen wrote:
> 
> > Define "works":
> 
>  >>> a = (1,2,3)
>  >>> b = ('a','b','c')
>  >>> c = (None, 'foo', 3.14)
>  >>> tup1 = (1,2,3)
>  >>> tup2 = ('a','b','c')
>  >>> tup3 = (None, 'foo', 3.14)
>  >>> for a,b,c in (tup1,tup2,tup3):
> ...   print a
> ...   print b
> ...   print c
> ...
> 1
> 2
> 3
> a
> b
> c
> None
> foo
> 3.14
>  >>>
> 
> It's a valid interpretation of the OP's
> ambiguously stated requirements, though probably
> not the right one.
> 

I can see that now.  I had three hours sleep last night and my brain
hurts, so I don't get it.  I seek enlightenment.

Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours



More information about the Python-list mailing list