Skip to main content

Moose-like object system for Python

Project description

Synopsis

import elk


class Point(elk.Elk):
    x = elk.ElkAttribute(mode='rw', type=int)
    y = elk.ElkAttribute(mode='rw', type=int)

    def clear(self):
        self.x = 0
        self.y = 0


class Point3D(Point):
    z = elk.ElkAttribute(mode='rw', type=int)

    @elk.after('clear')
    def clear_z(self):
        self.z = 0

What is Elk?

Elk (homepage) is an object system for Python inspired by Moose for Perl. It implements many of the features of Moose including:

  • attribute delegation

  • default attribute values

  • lazy attribute initialisation

  • read-only attributes

  • required attributes

  • attribute type constraints

  • roles

  • method modifiers

Elk is written in pure Python and there are no dependencies beyond the standard library.

How does Elk differ from Moose?

Moose has many features that are not (yet) implemented in Elk.

While Elk tries to faithfully implement Moose paradigms and patterns in Python, it uses Python idioms and language features as much as possible. There are also some differences in terminology in order to be consistent with Python terminology or idioms.

There is not yet a namespace for Elk extensions, nor any convenient mechanism for extending it.

Installation

pip install elk

License

Elk is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Contributing

The Elk source code is available from https://github.com/frasertweedale/elk.

Bug reports, patches, feature requests, code review and documentation are welcomed.

To submit a patch, please use git send-email or generate a pull request. Write a well formed commit message. If your patch is nontrivial, update the copyright notice at the top of each changed file.

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

elk-0.1.tar.gz (32.8 kB view details)

Uploaded Source

File details

Details for the file elk-0.1.tar.gz.

File metadata

  • Download URL: elk-0.1.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for elk-0.1.tar.gz
Algorithm Hash digest
SHA256 097ef7a12b7c32c7ac7714b7a71e05541d31667126ce054fc27b8bdd2f584dec
MD5 33b96e25a0fe566c217b728cbdb4537f
BLAKE2b-256 fe68804e3f8a14b8f75ff06d20e89a106801093d4c97100b96ce2257e4f2beec

See more details on using hashes here.

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