Commits

Georg Bauer committed 5091d94

even more infrastructure

Comments (0)

Files changed (4)

+-*- restructuredtext -*-
+
+Dynamic Scope for Python
+================================
+
+This package implements simple dynamic scope syntactic sugar
+for Python. It allows to (IMO elegantly) use dynamically scoped
+variables where you need them with a scheme-like semantic.
+
+Install is quite standard:
+
+easy_install dynscope
+
+or just download the sources and run setup.py install. There are testcases
+you can run with setup.py test, too.
+
+I test and work with it under Python 2.6.
+
+How to use dynamically scoped variables
+----------------------------------------
+
+>>> from dynscope import flet, fluid
+>>> with flet(anton=5, berta=6):
+>>>     print fluid.anton*fluid.berta
+>>> print fluid.anton*fluid.berta
+
+The first print will print 30, the second one will raise an exception,
+since those variables are not defined.
+
+There is a base-layer of fluid definitions (think of them as normal globals,
+only that they are per-thread or per-coroutine if using for example gevent
+with full patching) that you can use, too. But it's often much better style
+to restrict fluids to the dynamic scope that actually expects them. Unrestricted
+globals are far more often the wrong choice than the right choice. But where
+you can make use of them is to set defaults for dynamically scoped variables
+so that functions can run outside flet scopes.
+

dynscope/__init__.py

+__version__ = '0.1'

dynscope/tests.py

+import unittest
+
+class TestCase000Fluid(unittest.TestCase):
+
+    def testSimple(self):
+        from dynscope import fluid
+        fluid.anton = 5
+        self.assertEqual(fluid.anton, 5)
+
 from setuptools import setup
-from lazypy import __version__
+from dynscope import __version__
 
 setup(
     version = __version__,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.