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
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.2.0.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file chibi_hybrid-1.2.0.tar.gz
.
File metadata
- Download URL: chibi_hybrid-1.2.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 470803b0e54456cc4c7f8df9ad73f81f50578480afc3cc049c88758fbdcd6b57 |
|
MD5 | 6cf7a89c69d9edc6831f9ee4fe0082b8 |
|
BLAKE2b-256 | 111fbcbf43517c64a289ea2e48884e49877fee79a93029705ecbe1cadde720ef |
File details
Details for the file chibi_hybrid-1.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: chibi_hybrid-1.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90e2074a93209f1884bdcf8d752ee03a98ca3427d1ff6037b6f9e8373f91801c |
|
MD5 | 157f848d2076e460152224011a37bde4 |
|
BLAKE2b-256 | 7c3cd006fe671664148931bbba605cfc21faa9ed90c635984b413d17bcf18332 |