Bind functions to only run once inside a desired scope.
Documentation
The Rig class exposes two methods: bind and free. Bind takes one argument: A name for a scope to bind the function.
Functions wrapped with bind will be called only once until the scope it is inside is freed.
Functions wrapped with free will free all the bound functions in a specific scope after the function’s execution.
Example:
import shibari
rig = shibari.Rig('ebi')
@rig.bind('ebi')
def timestamp():
return str(time.time())
@rig.free('ebi')
def finish():
pass
>>> t = timestamp()
>>> t2 = timestamp()
>>> assert t == t2
>>> finish()
>>> t3 = timestamp()
>>> t4 == timestamp()
>>> assert t != t3
>>> assert t3 == t4
Functions that take arguments can be bound, but will always return the same result until they are freed.
Example:
import shibari
rig = shibari.Rig('ebi')
@rig.bind('ebi')
def timestamp(a, b):
return f'{a}_{str(time.time())}_{b}'
>>> t = timestamp('goodbye', 'world')
>>> t2 = timestamp('hello', 'space')
>>> assert t == t2
Release files for shibari 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shibari-0.0.2.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shibari-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / shibari-0.0.2.tar.gz
| Download URL | shibari-0.0.2.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53856bbd99b54acafa5ec0676cff1810a49233904610fce75969b591734a465c
|
|
BLAKE2b-256 checksum How to use checksums |
247af80bed4a35298ee0d0e7e4dd94c810386e1bd8c3f92f64b60b71129b1875
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.1
|
Release files / shibari-0.0.2-py3-none-any.whl
| Download URL | shibari-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b38f837c9279b1e30c0c9a0d7dbd3f4086446008ba4bf2fc98d2f8f9b311f306
|
|
BLAKE2b-256 checksum How to use checksums |
ddf7b78559506ecb906076bb5af72d9280d2b84f75c3455f5ff954f9e3250ed2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.1
|