D,T=[dict((x.split('.')[0],x) for x in X) for X in (dat,txt)]
for k in sorted(set(D).union(T)) :
for S in D,T :
print '%-8s' % S.get(k,'None'),
print
HTH
W. eWatson wrote:
Maybe there's some function like zip or map that does this. If not, it's
probably fairly easy to do with push and pop. I'm just checking to see
if there's not some known simple single function that does what I want.
Here's what I'm trying to do.
I have a list dat like (assume the items are strings even thought I'm
omitting quotes.):
[a.dat, c.dat, g.dat, k.dat, p.dat]
I have another list called txt that looks like:
[a.txt, b.txt, g.txt, k.txt r.txt, w.txt]
What I need is to pair up items with the same prefix and use "None", or
some marker, to indicate the absence of the opposite item. That is, in
non-list form, I want:
a.dat a.txt
None b.txt
c.dat None
g.dat g.txt
k.dat k.txt
p.dat None
None r.txt
None w.txt
Ultimately, what I'm doing is to find the missing member of pairs.
--
http://mail.python.org/mailman/listinfo/python-list