<div dir="ltr">Thanks for the insight, while this code will run once a week and optimization isn't really a must here, it is <br>still  a good idea not to leave half-baked code behind me, especially given that it will be running on this server  for the next  13 years ;)<br>
I have one doubt though . Doesn't using the list comprehension here increase number of loops per the same string ?<br>for nnn in [x.split() for x in hhh]:<br>My vision here is that after doing the comprehension it would look:<br>
for nnn in [1st_field,2nd_field,3rd_filed,...,nth_filed]: <br>... and therefore would do number of loops equal to number of fields while we really need just one ?<br><br>Thanks<br>Yuri<br><br><br><div class="gmail_quote">
On Tue, Apr 12, 2011 at 3:50 PM, D'Arcy J.M. Cain <span dir="ltr"><<a href="mailto:darcy@druid.net">darcy@druid.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
On Tue, 12 Apr 2011 15:06:25 +0300<br>
<div class="im">Yuri Slobodyanyuk <<a href="mailto:yuri.slobodyanyuk@gmail.com">yuri.slobodyanyuk@gmail.com</a>> wrote:<br>
</div><div class="im">> Thanks everybody , and especially Chris - i used split and it took me 15<br>
> mins to make it work :)<br>
<br>
</div>That's great.  One thing though...<br>
<div class="im"><br>
> for nnn in hhh:<br>
>     if nnn.split()[2] == str(time_tuple[1]).strip(' \t\n\r')   and<br>
> nnn.split()[4]  == str(time_tuple[0]).strip(' \t\n\r') and  nnn.split()[3]<br>
> == str(time_tuple[2]).strip(' \t\n\r')   :<br>
<br>
</div>You are running split() on the same string three times and running<br>
strip on the same time tuple each time through the loop.  I know that<br>
you shouldn't optimize before testing for bottlenecks but this is just<br>
egrecious as well as making it more difficult to read.  Consider this.<br>
<br>
year = str(time_tuple[0]) # strip() not really needed here<br>
mon = str(time_tuple[1])<br>
day = str(time_tuple[2])<br>
<br>
for nnn in [x.split() for x in hhh]:<br>
    if nnn[2] == mon and nnn[3] = day and nnn[4] = year:<br>
<br>
If strip() were needed you could leave off the argument.  The default<br>
is to strip all whitespace from both ends.  In fact, read up on locales<br>
to see why it is a good idea to omit the argument.<br>
<font color="#888888"><br>
--<br>
D'Arcy J.M. Cain <<a href="mailto:darcy@druid.net">darcy@druid.net</a>>         |  Democracy is three wolves<br>
<a href="http://www.druid.net/darcy/" target="_blank">http://www.druid.net/darcy/</a>                |  and a sheep voting on<br>
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><div>Taking challenges one by one.</div>
<div><a href="http://yurisk.info/" target="_blank">http://yurisk.info</a></div>
<div><a href="http://ccie-security-blog.com/" target="_blank">http://ccie-security-blog.com</a></div>
<div> </div>
<div> </div></div><br>
</div>