flexibility when you need it
Project description
ambiguous
flexibility when you need it
Install
pip install ambiguous
Usage
decorator: allow decorators to accept arguments
from ambiguous import decorator
@decorator
def power(fn, exponent=2):
'''take function results and raise to an exponent'''
return lambda x: fn(x) ** exponent
@power
def squared(x): return x
squared(2)
> 4
@power(exponent=3)
def cubed(x): return x
cubed(2)
> 8
thing_or_things: combine gets and multigets
from ambiguous import thing_or_things
@thing_or_things
def itself(args):
return { x : x for x in args }
itself(1)
> 1
itself([1, 2])
> { 1 : 1, 2 : 2 }
# specify which argument
@thing_or_things('args')
def prefix(prefix, args):
return { x : "%s_%s" % (prefix, x) for x in args }
prefix('abc', [1, 2])
> { 1 : 'abc_1', 2 : 'abc_2' }
optional parentheses (warning: still experimental)
import ambiguous
@ambiguous
def foo():
return 'foo'
# the usual
foo()
> 'foo'
# ?!?
foo
> 'foo'
foo + 'abc'
> 'fooabc'
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ambiguous-0.5.0.tar.gz
(10.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ambiguous-0.5.0.tar.gz.
File metadata
- Download URL: ambiguous-0.5.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c5d9b89c5cb04a186265ba3796b9e3d429ca6d01a942939382d90f7106fc63e
|
|
| MD5 |
2d6e309db44008fc7e88f7a5a8f547f0
|
|
| BLAKE2b-256 |
fa34ac4555e0f1a6c0353d33347e8bff449347bdd30476ef54d2efde08d2c96b
|
File details
Details for the file ambiguous-0.5.0-py3-none-any.whl.
File metadata
- Download URL: ambiguous-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4ea535362e95f0032521dc33a89d549d24208cf88988ad06d5de8f3fdc263e4
|
|
| MD5 |
acbf15ccccf5673df2dc35d5b56628ca
|
|
| BLAKE2b-256 |
417f99905cc12a3e8bd0a5172acfa1708a789b2c6fb57403f1f98cf1c15663d7
|