summaryrefslogtreecommitdiff
path: root/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-05-09 13:42:58 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-05-09 13:42:58 +0000
commit5aa46e8d12bd92b7d541ddd22fa81a8164deb46f (patch)
tree3f6b49db491a209d70ca0107387ff8da0bacd98b /sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py
parenta37d1d928b4a49c118bb17c0d49b09f1fc1e685b (diff)
downloaddocutils-5aa46e8d12bd92b7d541ddd22fa81a8164deb46f.tar.gz
Clean up code-block-directive sandbox project.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7430 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py')
-rw-r--r--sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py92
1 files changed, 0 insertions, 92 deletions
diff --git a/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py b/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py
deleted file mode 100644
index 4bb941dd6..000000000
--- a/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/for-else-test.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# Example for syntax highlight with Pygments
-# ==========================================
-#
-# Translate this document to HTML with a pygments enhanced frontend::
-#
-# rst2html-pygments --stylesheet=pygments-default.css
-#
-# or to LaTeX with::
-#
-# rst2latex-pygments --stylesheet=pygments-default.sty
-#
-# to gain syntax highlight in the output.
-#
-# Convert between text <-> code source formats with::
-#
-# pylit --code-block-marker='.. code-block:: python'
-#
-# Run the doctests with::
-#
-# pylit --doctest for-else-test.py
-#
-#
-# for-else-test
-# -------------
-#
-# Test the flow in a `for` loop with `else` statement.
-#
-# First define a simple `for` loop.
-#
-# .. code-block:: python
-
-def loop1(iterable):
- """simple for loop with `else` statement"""
- for i in iterable:
- print i
- else:
- print "iterable empty"
- print "Ende"
-
-# Now test it:
-#
-# The first test runs as I expect: iterator empty -> else clause applies:
-#
-# .. code-block:: pycon
-#
-# >>> execfile('for-else-test.py')
-# >>> loop1(range(0))
-# iterable empty
-# Ende
-#
-# However, the else clause even runs if the iterator is not empty in the first
-# place but after it is "spent":
-#
-# .. code-block:: pycon
-#
-# >>> loop1(range(3))
-# 0
-# 1
-# 2
-# iterable empty
-# Ende
-#
-# It seems like the else clause can only be prevented, if we break out of
-# the loop. Let's try
-#
-# .. code-block:: python
-
-def loop2(iterable):
- """for loop with `break` and `else` statement"""
- for i in iterable:
- print i
- break
- else:
- print "iterable empty"
- print "Ende"
-
-# And indeed, the else clause is skipped after breaking out of the loop:
-#
-# .. code-block:: pycon
-#
-# >>> loop2(range(3))
-# 0
-# Ende
-#
-# The empty iterator runs as expected:
-#
-# .. code-block:: pycon
-#
-# >>> loop2(range(0))
-# iterable empty
-# Ende
-#