Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Newbie: Struggling again 'map'

View parsed - Show only message text

Path: g2news1.google.com!postnews.google.com!p77g2000hsh.googlegroups.com!not-for-mail
From: Dan Bishop <danb...@yahoo.com>
Newsgroups: comp.lang.python
Subject: Re: Newbie: Struggling again 'map'
Date: 26 May 2007 03:21:16 -0700
Organization: http://groups.google.com
Lines: 30
Message-ID: <1180174876.941308.37200@p77g2000hsh.googlegroups.com>
References: <1180173252.906992.262570@q75g2000hsh.googlegroups.com>
NNTP-Posting-Host: 72.177.181.97
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1180174877 4320 127.0.0.1 (26 May 2007 10:21:17 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 26 May 2007 10:21:17 +0000 (UTC)
In-Reply-To: <1180173252.906992.262570@q75g2000hsh.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: p77g2000hsh.googlegroups.com; posting-host=72.177.181.97;
   posting-account=U2kTDQwAAACh4bipJkJPrjlruWGdlLaM

On May 26, 4:54 am, mosscliffe <mcl.off...@googlemail.com> wrote:
> I thought I had the difference between 'zip' and 'map' sorted but when
> I try to fill missing entries with something other than 'None'. I do
> not seem to be able to get it to work - any pointers appreciated.
>
> Richard
>
> lista = ['a1', 'a2']
> listb = ['b10', 'b11','b12' ,'b13']
>
> for x,y in zip(lista, listb):    #  Fine Truncates as expected
>     print "ZIP:", x, "<<x  y>>", y
>
> for x,y in map(None, lista, listb):  #  Also fine - extends as
> expected
>     print "MAP:", x, "<<x  y>>", y
>
> for x,y in map("N/A", lista, listb): ########## Fails - Can not call a
> 'str'
>     print "MAP:", x, "<<x  y>>", y
>
> def fillwith(fillchars):
>     return fillchars
>
> for x,y in map(fillwith("N/A"), lista, listb): ########## Fails also -
> Can not call a 'str'
>     print "MAP:", x, "<<x  y>>", y

zip(lista + ['N/A'] * 2, listb)


Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google