Login | Register
My pages Projects Community openCollabNet

Discussions > dev [DISABLED] > hot-backup.py weird for-else clause

subversion
Discussion topic

Back to topic list

hot-backup.py weird for-else clause

Author stsp
Full name Stefan Sperling
Date 2010-02-01 07:06:43 PST
Message Hi,

consider this snippet from hot-backup.py.in:

  if retry:
    for delay in (0.5, 1, 2, 4):
      try:
        rmtree(dirname)
        break
      except:
        time.sleep(delay)
    else:
      rmtree(dirname)
  else:
    rmtree(dirname)

I don't think an 'else' clause to a for-loop makes any sense,
right? Is this a legal python construct I wasn't aware of,
or simply a mistake?

Proposed patch:

Index: hot-backup.py.in
====================​====================​====================​=======
--- hot-backup.py.in (revision 905260)
+++ hot-backup.py.in (working copy)
@@ -82,8 +82,6 @@
         break
       except:
         time.sleep(delay)
- else:
- rmtree(dirname)
   else:
     rmtree(dirname)
 
Stefan

« Previous message in topic | 1 of 2 | Next message in topic »

Messages

Show all messages in topic

hot-backup.py weird for-else clause stsp Stefan Sperling 2010-02-01 07:06:43 PST
     Re: hot-backup.py weird for-else clause cmpilato C. Michael Pilato 2010-02-01 07:39:31 PST
Messages per page: