simple class for have hybrid class and instance methods
Project description
chibi_hybrid
simple class for have hybrid class and instance methods and add class properties
Free software: WTFPL
Documentation: https://chibi-hybrid.readthedocs.io.
Features
from chibi_hybrid.chibi_hybrid import Chibi_hybrid, Class_property
class Dump:
__bar = ''
def __init__( self, value ):
self.value = value
@Chibi_hybrid
def foo( cls ):
return cls( 'cls' )
@foo.instancemethod
def foo( self ):
return self.value
@Class_property
def bar( cls ):
return cls.__bar
@bar.setter
def bar( cls, value ):
cls.__bar = value
result = Dump.foo()
assert result == Dump
assert 'cls' == result.value
assert 'cls' == result.foo()
result = Dump( 'cosa' ).foo()
assert 'cosa' == result
assert Dump.bar == ''
Dump.bar = "cosa 2"
assert Dump.bar == 'cosa 2'
History
0.0.1 (2019-10-31)
First release on PyPI.
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
chibi_hybrid-1.0.0.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for chibi_hybrid-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ba43edb4f45a4613f829fd71eb1f7537d6d7c4f50c293006e92fbcf75acc9b6 |
|
MD5 | eb3a5d12e987eafd396f9af783868b6e |
|
BLAKE2b-256 | 471c7678d720666cdc64cc7afa7dcc3f840a595adf27a1213e31d7b5c4980c94 |