[Fwd: Re: [Tutor] Matrix Transpose]
Cliff Wells
logiplex at qwest.net
Fri Aug 29 16:47:18 EDT 2003
On Fri, 2003-08-29 at 10:11, Lloyd Kvam wrote:
> I must have clicked Reply rather than reply-All.
>
> ______________________________________________________________________
> From: Lloyd Kvam <pythontutor at venix.com>
> To: G Kiran <goki75 at vsnl.net>
> Subject: Re: [Tutor] Matrix Transpose
> Date: Fri, 29 Aug 2003 09:38:56 -0400
>
> >>> tb = map(None,*a)
> >>> tb
> [(1, 1, 1), (2, 2, 2), (3, 3, 3), (None, 4, None)]
> This pads with None's.
Please forgive this one-liner:
data = """
1,2,3
1,2,3,4
4,5,6,7
"""
zip(*map(lambda *args: map(lambda a: a is not None and int(a) or 0,
args), *[row.split(',') for row in data.split('\n') if row]))
Regards,
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555
More information about the Tutor
mailing list