Login | Register
My pages Projects Community openCollabNet

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

subversion
Discussion topic

Back to topic list

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

Author cmpilato
Full name C. Michael Pilato
Date 2010-02-01 07:39:31 PST
Message 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.o​rg/tutorial/controlf​low.html#break-and-c​ontinue-statements-a​nd-else-clauses-on-l​oops

--
C. Michael Pilato <cmpilato at collab dot net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Attachments

« Previous message in topic | 2 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: