Prototype-Oriented Programming in Python
Project description
protoclass
[] []
Prototype-Oriented Programming in Python.
Installation
pip install protoclass
Usage
from protoclass import proto
# We create a basic object and add some functionality
jane = proto(first="Jane", last="Doe")
jane.greet = lambda self: print(self)
jane.greet()
# >>> <proto object at ...>
# Oh no, we want something prettier...
# We could modify the `greet` function...
# Or we could create a `person` object an inherit from it
person = proto(first="", last="")
person.__str__ = lambda self: f"{self.first} {self.last}"
jane.link(person)
# Now we get a nicer greeting
jane.greet()
# >>> Jane Doe
API Reference
proto(**kwargs) |
Make a new prototype object with the given attributes. If no properties are given, and empty prototype will be created. The latter is useful when only a clone of another object is needed. |
proto.link(self, other) |
Make current object a prototype of another object. This is similar to single inheritance. Each object can have multiple child links, but only one parent link. Parent links can be changed at any time, but objects that are children of this one will be affected by this. This enables change propagation. |
License
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
protoclass-0.0.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for protoclass-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec001137de3b25cc995c78ead3f8ab58053b77336473f4063521021402bee631 |
|
MD5 | 7b433e1d6c254d0e485f1b77c1faa7e9 |
|
BLAKE2b-256 | 32e5ea3cdf614488393454a492f25c8143356ce208f097776b112bbccb0beedb |