I think this is overkill for what I'm trying to do, could you please refer to what I just wrote luke? That might make things simpler.. <br><br><div><span class="gmail_quote">On 10/18/06, <b class="gmail_sendername">John Fouhy
</b> &lt;<a href="mailto:john@fouhy.net">john@fouhy.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Ok, so your question is:
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If nothing in directoryList matches item, how do I find the<br>element of directoryList that should have matched?<br><br>This is a bit tricky, because you need to define exactly what results<br>you expect.<br>
<br>(for example, suppose limitedLineList contained 'SL_39.sdr' and<br>directoryList had 'SL39.sdr'.&nbsp;&nbsp;Is that something that should be a<br>match?)<br><br>Possibly you could do this:<br><br>def match(item, lst):<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot; See if item is present in lst.
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;output :: bool<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;return item in lst<br><br>def near_match(item, lst):<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot; See if item is similar to something in lst. Currently, we just<br>match case-insensitive.
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;output :: first matching element of lst, or None<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;for item2 in lst:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if item.upper() == item2.upper():<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return item2<br>&nbsp;&nbsp;&nbsp;&nbsp;return None<br><br>for item in limitedLineList:
<br>&nbsp;&nbsp;&nbsp;&nbsp;if match(item, directoryList):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print '%20s%20s%20s' % ('Match!', item, item)<br>&nbsp;&nbsp;&nbsp;&nbsp;else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item2 = near_match(item, directoryList)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if item2:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print '%20s%20s%20s' % ('Fail!', item, item2)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print '%20s%20s%20s' % ('Fail!', item, '????')<br><br>You can modify near_match if you have some other definition of what<br>you want it to return.<br><br>--<br>John.<br>_______________________________________________
<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>