Skip to main content

Delegate

A python library for delegation (the metaprogramming feature)

This library adds the @delegate decorator which may be used to delegate attributes from an attribute of the existing class. For example:

from delegate import delegate

class Parent:
    def __init__(self):
        self.a = "a"
        self.b = "b"
        self.d = "d"

# The delegate decorator makes .a and .b available on Child, through its
# "parent" attribute, as though Child had an a and b attribute itself.
@delegate("a", "b", to="parent")
class Child:
    def __init__(self):
        self.parent = Parent()
        self.c = "c"

instance = Child()
assert instance.a == "a"
raised = False
try:
    # But d is not available
    instance.d
except e:
    raised = True

assert raised

Download files

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

Source Distribution

delegate_property-0.1.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

delegate_property-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file delegate_property-0.1.0.tar.gz.

File metadata

  • Download URL: delegate_property-0.1.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for delegate_property-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52f2ab303b187e16c391356b114c69f410ff84560e0444ea8206f3196c08ffab
MD5 b4800f7b293480de7887ed89d8622dc1
BLAKE2b-256 0f27e752d3c4fbcb1ccf4fd590014a0d7558b779501e3c993143a4cccc990457

See more details on using hashes here.

File details

Details for the file delegate_property-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: delegate_property-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for delegate_property-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf9628e14984abbb425f53f203bad6c586aa9daa2a1227b09ddc277cc51cb28d
MD5 a1dfa218de0acb9309a6dc3d6c97aa5b
BLAKE2b-256 3ac7dc178d42c3bf2b30d4cb4e7fc2a82097e6b136636f28856a16c173296c42

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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