Loop structures: Difference between revisions

Content added Content deleted
(Added Perl)
(Added Python)
Line 172: Line 172:
# Remember to change the value of condition1 at some point.
# Remember to change the value of condition1 at some point.
} until ( $condition1 );
} until ( $condition1 );

==[[Python]]==
[[Category:Python]]

===with===

'''Interpreter''': Python 2.5

foo could for example open a file or create a lock or a database transaction:

with foo() as bar:
baz(bar)


===while===

while ok():
foo()
bar()
baz()
else:
# break was not called
quux()

===for===

for i in range(10):
print i
else:
# break was not called
foo()