Skip to main content

Set a Python property using a function call

Project description

caller

Build Status Code style: black

Caller is a little library for calling a property as a regular function.

Installation

Install using pip:

$ pip install caller

Usage

from caller import property

class Foo(object):
    def __init__(self, bar):
        self._bar = bar

    @property
    def bar(self):
        return self._bar

    @bar.setter
    def bar(self, new_bar):
        self._bar = new_bar

foo = Foo('bar')
foo.bar('new bar')

print(foo.bar)

Prints

new bar

Or with a separate caller

class Foo(object):
    ...
    @bar.caller
    def bar(self, new_bar):
        self._bar = new_bar[::-1]
        print(self._bar)

Foo('bar').bar('new bar')

Prints

rab wen

That's all.

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

caller-0.0.2.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file caller-0.0.2.tar.gz.

File metadata

  • Download URL: caller-0.0.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for caller-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4dd3b5bf814c0faba5bc580c8969a6ac81b6af918499ce5a157e0157a6775456
MD5 facb7ed868fd9aa9589371a1a6b86451
BLAKE2b-256 82a47a32694a0ad44f7f210ceaee3829e739e87f3e8e1e0e4595da371dd32f16

See more details on using hashes here.

Provenance

Supported by

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