Skip to main content

Assorted decorator functions.

Function decorator(deco)

Wrapper for decorator functions to support optional arguments. The actual decorator function ends up being called as:

deco(func, *da, **dkw)

allowing da and dkw to affect the bahviour of the decorator deco.

Examples:

@decorator
def deco(func, *da, kw=None):
  ... decorate func subject to the values of da and kw
@deco
def func1(...):
  ...
@deco('foo', arg2='bah')
def func2(...):
  ...

Function fmtdoc(func)

Decorator to replace a function's docstring with that string formatted against the function's module's dict.

This supports simple formatted docstrings:

ENVVAR_NAME = 'FUNC_DEFAULT'

@fmtdoc
def func():
    """Do something with os.environ[{ENVVAR_NAME}]."""
    print(os.environ[ENVVAR_NAME])

This gives func this docstring:

Do something with os.environ[FUNC_DEFAULT].

Warning: this decorator is intended for wiring "constants" into docstrings, not for dynamic values. Use for other types of values should be considered with trepidation.

Function observable_class(property_names, only_unequal=False)

Class decorator to make various instance attributes observable.

Parameters:

  • property_names: an interable of instance property names to set up as observable properties. As a special case a single str can be supplied of only one attribute is to be observed.
  • only_unequal: only call the observers if the new property value is not equal to the previous proerty value. This requires property values to be comparable for inequality. Default: False, meaning that all updates will be reported.

Metadata

Release files for cs-deco 20190526

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-deco 20190526
File Size Uploaded Provenance
cs.deco-20190526.tar.gz 5.6 kB Without provenance Details

Release files / cs.deco-20190526.tar.gz

Download URL cs.deco-20190526.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
760523e13e332f3760c8c45749af5ce6d45556c3d424efe949990b777f4fb4b1
BLAKE2b-256 checksum
How to use checksums
b239d7c913a27fe17a10ade082d655846c6c9926221ceb68e7642048c7fcad3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Security for cs-deco 20190526

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

20190526 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page