Dynamic Scope for Python
Project description
-- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dynscope-0.1.tar.gz
.
File metadata
- Download URL: dynscope-0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5878c103b1512df0e9f62f45429b10ce495975d1cdd66227677ee7d0abeefbf5 |
|
MD5 | 798695ac85a20c60314264b1357ec797 |
|
BLAKE2b-256 | d9413115657757e019a749e9046794d841c2c5f58553947d1ed1f30d709dd42c |
File details
Details for the file dynscope-0.1-py2.6.egg
.
File metadata
- Download URL: dynscope-0.1-py2.6.egg
- Upload date:
- Size: 9.1 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86df643e3de5c20c7a1353adabbc525b3c792ab54682d9e66d87e88f18a71943 |
|
MD5 | 2201eaa3a4556f0fb4f86528c2521f7e |
|
BLAKE2b-256 | 31b9fe800af075376dbcb16f2b19e18a81e2a9d30f4ffe3082ea45072afd6f54 |