map(None, North, South, East West) does exactly what you want:
>>> North=['Bill', 'Bob', 'Sue', 'Mary']
>>> South=['Tim', 'Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
>>> map(None, North, South)
[('Bill', 'Tim'), ('Bob', 'Tom'), ('Sue', 'Jim'), ('Mary', 'John'), (None,
'Carl'), (None, 'Evan
Tony Cappellini wrote:
I havne't seen Kent's reply yet- will have to look when I get home from
work.
But I 've found some inconsistnacies with map, depending on which order
the args were passed in.
If the shorter list was passed to map first, as in map(shortlist,
longerlist), it behaved one way.
Th
LOL
> Here's one, just for your amusement:
>
> But getting back on topic: I like Kent's solution with map() much better
> than my own. I had completely forgotten that map() had a special case
> that applies directly to what you're trying to do.
I havne't seen Kent's reply yet- will have to look
On Mon, 7 Feb 2005, Tony Cappellini wrote:
> > Here's a quick function that should force a certain length on an
> > iterator:
> >
> > ###
> > def ipad(iterable, length, sentinel=None):
> > i = 0
> > for thing in iterable:
> > yield thing
> > i = i + 1
> > while i < le
> How about using a try loop every time you read from
> the list.
try is not a loop.
> try:
>x=list[someno]
> except:
>x=nothing(or whatever)
>
> This goes on till the all lists start returning none.
No, sorry it just does it once.
try/except is for detecting errors not a looping constr
> Out of curiosity, if it's not possible to run zip() directly on the lists
> that you have, can you bend the lists so that zip() will fit?
It is possible, however zip() truncates the longer list, based on the size
of the smaller list, so it's just not feasible in my case.
> Here's a quick functi
Tony Cappellini wrote:
I'm trying to generate an HTML table, from multiple lists.
There are 4 lists total, each of which *may* have a different length
from the other lists.
Each list has been stored in a master dictionary.
North=[Bill, Bob, Sue, Mary]
South=['Tim', ''Tom', 'Jim', 'John', 'Carl',
On Mon, 7 Feb 2005, Tony Cappellini wrote:
> There are 4 lists total, each of which *may* have a different length
> from the other lists. Each list has been stored in a master dictionary.
>
> North=[Bill, Bob, Sue, Mary]
> South=['Tim', ''Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
> etc
>
> I
Hi,
My solution might raise purist's eyebrows but here it
goes...
How about using a try loop every time you read from
the list.
try:
x=list[someno]
except:
x=nothing(or whatever)
This goes on till the all lists start returning none.
for shorter lists try throws an index out of range
excepti
I'm trying to generate an HTML table, from multiple lists.
There are 4 lists total, each of which *may* have a different length from
the other lists.
Each list has been stored in a master dictionary.
North=[Bill, Bob, Sue, Mary]
South=['Tim', ''Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
etc
d1
10 matches
Mail list logo