Skip to main content

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'

installs

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.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ambiguous-0.5.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file ambiguous-0.5.1.tar.gz.

File metadata

  • Download URL: ambiguous-0.5.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ambiguous-0.5.1.tar.gz
Algorithm Hash digest
SHA256 8ecd2957458fcfc7be224cfdd59795033b23c8c6a2a6e79f8059feb093f23034
MD5 d42dda661bc9b2fe3ab15b39d8ecdbe0
BLAKE2b-256 4184aa41d8cb65644eacb88e6eb289e6aefd59cf861b6b26b859a5da89080270

See more details on using hashes here.

Provenance

The following attestation bundles were made for ambiguous-0.5.1.tar.gz:

Publisher: pypi.yml on dpep/py_ambiguous

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ambiguous-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: ambiguous-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ambiguous-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db38d0981afce5adda1a7eb2c944d5a03eae3090c72c845a395e78f4e53002be
MD5 7badca53f2096786fcc6795d83565458
BLAKE2b-256 650e89027d71b45a0d0fa60836e77d047ee2324c85cf1593cdca152bc0f60062

See more details on using hashes here.

Provenance

The following attestation bundles were made for ambiguous-0.5.1-py3-none-any.whl:

Publisher: pypi.yml on dpep/py_ambiguous

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page