1 Example for syntax highlight with Pygments
2 ==========================================
4 Translate this document to HTML with a pygments enhanced frontend::
6 rst2html-pygments --stylesheet=pygments-default.css
10 rst2latex-pygments --stylesheet=pygments-default.sty
12 to gain syntax highlight in the output.
14 Convert between text <-> code source formats with::
16 pylit --code-block-marker='.. code-block:: python'
18 Run the doctests with::
20 pylit --doctest for-else-test.py
26 Test the flow in a `for` loop with `else` statement.
28 First define a simple `for` loop.
30 .. code-block:: python
33 """simple for loop with `else` statement"""
37 print "iterable empty"
42 The first test runs as I expect: iterator empty -> else clause applies:
46 >>> execfile('for-else-test.py')
51 However, the else clause even runs if the iterator is not empty in the first
52 place but after it is "spent":
63 It seems like the else clause can only be prevented, if we break out of
66 .. code-block:: python
69 """for loop with `break` and `else` statement"""
74 print "iterable empty"
77 And indeed, the else clause is skipped after breaking out of the loop:
85 The empty iterator runs as expected: