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

"C. Michael Pilato" <[email protected]> Mon, 01 Feb 2010 10:39:20 -0500
Newsgroups gmane.comp.version-control.subversion.devel,gmane.comp.version-control.subversion.rapidsvn.devel
Organization CollabNet, Inc.
Message-ID <[email protected]>
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 <[email protected]>
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 <[email protected]> mailing list.
To subscribe to the new list, send an empty e-mail to <[email protected]>.
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAktm9bAACgkQokEGqRcG/W7bNQCdGlUiIx/0TPORjXKi+oM7v1vt
jv8AoLy4dHb89gDB5HpERNHRiRE89Hf2
=YKfB
-----END PGP SIGNATURE-----