[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: hot-backup.py weird for-else clause

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: Mon, 01 Feb 2010 10:39:20 -0500

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 <cmpilato_at_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 <dev_at_subversion.apache.org> mailing list.
To subscribe to the new list, send an empty e-mail to <dev-subscribe_at_subversion.apache.org>.

Received on 2010-02-01 16:39:52 CET

This is an archived mail posted to the Subversion Dev mailing list.