Skip to main content

An apply function for Python 2 and 3

Project description

Package Contents

apply(object, args=None, kwargs=None)

Call object with args and kwargs; return its results.

Overview

Python 3 has no apply. We like apply. I you like apply as well, have no fear. This version of apply works across all versions of Python.

Examples

apply allows to create read/write properties in a very compact way:

from apply import apply

class X509:

    def __init__(self, store):
        self.store = store

    @apply
    def CN():
        doc = 'The common name attribute'
        def get(self):
            return self.store.get('CN')
        def set(self, value):
            self.store.put('CN', value)
        return property(get, set, doc=doc)

record = X509(LDAP())
record.CN = 'Slate Rock and Gravel Company/emailAddress=cert@slaterock.com'

Changelog

1.1 - 2011-11-26

  • Fix function signature. [stefan]

1.0 - 2011-11-25

  • Initial release. [stefan]

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

apply-1.1.zip (5.5 kB view details)

Uploaded Source

File details

Details for the file apply-1.1.zip.

File metadata

  • Download URL: apply-1.1.zip
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for apply-1.1.zip
Algorithm Hash digest
SHA256 e3bdd8cddf23f810d9b58f84d79af305f5ddd905e1172f6b6e45294de3516f36
MD5 456a60820728ad608defe5ed6406a49d
BLAKE2b-256 0e85629fe95ad496b2c8c5be9ceb46a2a0a109745e6989ab1d011192b8520512

See more details on using hashes here.

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