Commits

Jonathan Fine committed 859b67b Draft

Add example_template_function.py # Not that it does anything useful.

Comments (0)

Files changed (2)

py2/jfine/example_template_function.py

+def f(extend, script):
+    locs = locals()
+    for flag, fn in script:
+        if False:
+            pass
+        elif flag == 1:
+            a, b = fn(locs)
+            extend((
+                    'A',
+                    a,
+                    b,
+                    'C',
+                    c,
+                    ))
+        elif flag == 2:
+            c,  = fn(locs)
+            extend((
+                    'a',
+                    ))
+        elif flag == 3:
+            a, c = fn(locs)
+            extend((
+                    'b',
+                    b,
+                    ))

py2/jfine/work.py

 __metaclass__ = type
 
 
-# Example of a template function.  All it needs is a script.
-def f(extend, script):
-    locs = locals()
-    for flag, fn in script:
-        if False:
-            pass
-        elif flag == 1:
-            a, b = fn(locs)
-            extend((
-                    'A',
-                    a,
-                    b,
-                    'C',
-                    c,
-                    ))
-        elif flag == 2:
-            c,  = fn(locs)
-            extend((
-                    'a',
-                    ))
-        elif flag == 3:
-            a, c = fn(locs)
-            extend((
-                    'b',
-                    b,
-                    ))
-
+# See example_template_function.py.  To be useful all it needs is a
+# script.
 
 def indent_and_format(s):