A set of useful python classes to inherit from
Project description
Overview
This set of libraries is intended to provide useful classes to inherit from, in a way that is cross compatible between multiple languages. A version of this library is currently available in:
Python (2 or 3)
Javascript
Singleton
The singleton class provides a way to ensure you only have one instance of a class. For instance:
from predecessor import Singleton
class Example(Singleton):
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
a = Example(3, 8)
b = Example(2, 9)
a is b # returns True
a.foo == b.foo == 3 # returns True
Or equivalently in Javascript:
const Singleton = require('predecessor').Singleton;
class Example extends Singleton {
constructor(foo, bar) {
this.foo = foo;
this.bar = bar;
}
}
let a = new Example(3, 8);
let b = new Example(2, 9);
a === b; // returns true
a.foo === 3; // returns true
b.foo === 3; // returns true
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
predecessor-0.0.2.tar.gz
(1.9 kB
view hashes)
Built Distribution
Close
Hashes for predecessor-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 762988c0ca9455a782283d47e800c523a149f1e0754ec17458c88f5b3ca75618 |
|
MD5 | 20dcfc79fc3aa60ec736a253dc56def2 |
|
BLAKE2b-256 | d0a49628269cd1d19214e7a86436bf4f4648f3bbeeb64738e3ff4650c43c3d09 |