Skip to main content

simple class for have hybrid class and instance methods

Project description

chibi_hybrid

https://img.shields.io/pypi/v/chibi_hybrid.svg https://img.shields.io/travis/dem4ply/chibi_hybrid.svg Documentation Status

simple class for have hybrid class and instance methods and add class properties

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.1.0.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

chibi_hybrid-1.1.0-py2.py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 2 Python 3

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