You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Stefan Sperling <st...@elego.de> on 2010/02/01 15:06:39 UTC
hot-backup.py weird for-else clause
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
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2443813
*** THIS LIST IS CLOSED ***
Please start new threads on the <de...@subversion.apache.org> mailing list.
To subscribe to the new list, send an empty e-mail to <de...@subversion.apache.org>.
Re: hot-backup.py weird for-else clause
Posted by "C. Michael Pilato" <cm...@collab.net>.
Stefan Sperling wrote:
> 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?
for-else is valid in Python, yes.
http://docs.python.org/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2443828
*** THIS LIST IS CLOSED ***
Please start new threads on the <de...@subversion.apache.org> mailing list.
To subscribe to the new list, send an empty e-mail to <de...@subversion.apache.org>.