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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cs.deco-20190526.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file cs.deco-20190526.tar.gz.

File metadata

  • Download URL: cs.deco-20190526.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for cs.deco-20190526.tar.gz
Algorithm Hash digest
SHA256 760523e13e332f3760c8c45749af5ce6d45556c3d424efe949990b777f4fb4b1
MD5 62b94b588709fc466e6f807dfe9c3fe0
BLAKE2b-256 b239d7c913a27fe17a10ade082d655846c6c9926221ceb68e7642048c7fcad3b

See more details on using hashes here.

Release history Release notifications | RSS feed

20260719

2 files

20260622

2 files

20260525

2 files

20251230

2 files

20250914

2 files

20250724

2 files

20250601

2 files

20250531

2 files

20250513

2 files

20250428

2 files

20250306

2 files

20250103

2 files

20241206

2 files

20241109

2 files

20241007

2 files

20241003

2 files

20240709

2 files

20240630

2 files

20240412

2 files

20240326

2 files

20240316

2 files

20240314.1

2 files

20240314

2 files

20240303

2 files

20240211

2 files

20231129

2 files

20230331

2 files

20230212

2 files

20230210

2 files

20221214

2 files

20221207

2 files

20221106.1

2 files

20221106

2 files

20220918.1

2 files

20220918

2 files

20220905

2 files

20220805

2 files

20220327

2 files

20220311

1 file

20220227

1 file

20210823

1 file

20210123

1 file

20201202

1 file

20201025

1 file

20201020

1 file

20200725

1 file

20200517.2

1 file

20200517.1

1 file

20200517

1 file

20200417

1 file

20200318.1

1 file

20200318

1 file

20191012

1 file

20191006

1 file

20191004

1 file

20190905

1 file

20190830.2

1 file

20190830.1

1 file

20190830

1 file

20190729

1 file

20190601.1

1 file

20190601

1 file

This release

20190526 This release

1 file

20190512

1 file

20190404

1 file

20190403

1 file

20190322.1

1 file

20190322

1 file

20190309

1 file

20190307.2

1 file

20190307.1

1 file

20190307

1 file

20190220

1 file

20181227

1 file

20171231

1 file

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