Help with python code!

Roy Smith roy at panix.com
Sun Mar 31 17:13:49 EDT 2013


In article <2912c674-e30b-4339-9344-1f460cb96b23 at googlegroups.com>,
 jojo <gerrymcgovern at gmail.com> wrote:

> for fname in dirList:
>  cmd = "keytool ­printcert ­file " + fname
>  for line in os.popen(cmd).readlines():
>    line = line.rstrip()
>    m = p.search(line)
>    if m:
>       sue = time.mktime(
>         (int(m.group(7)), int(months[m.group(2)]), int(m.group(3)),
>           int(m.group(4)), int(m.group(5)), int(m.group(6)),
>           int(days[m.group(1)]), 0, 0)
>         )
>         expire_time = (sue ­ current_time)/60/60/24
>         if expire_time < 0:
>           print cert_name + " has already expired!"
>         elif expire_time < 31:
>           print cert_name + " expires in " +str(int(expire_time)) + " days"
>        else:
>         m = q.search(line)
>         if m:
>         cert_name = m.group(1)

Was this code really indented like this when you got it?  You've got (at 
least) three different indent sizes.  I see 1, 2, and 3 space indents in 
different places in the code.

I'm not even sure if this is legal, but even if it is, it's really bad 
form.  Pick an indent, and stick with it uniformly.  4 spaces seems to 
be pretty standard.

That being said, I'm going to return to my previous statement that until 
you know what the code is *supposed* to do, trying to test it is 
meaningless.



More information about the Python-list mailing list