Metadata-Version: 2.4
Name: classspace
Version: 0.1.0
Summary: StaticSpace, DecorateClass, LabelEnum - Python class utilities
Author-email: 273 <nf273_@outlook.com>
Project-URL: Homepage, https://github.com/273/classspace
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Dynamic: license-file

# classspace

Python 类工具库：静态空间、装饰器包装、枚举类

## 安装

pip install classspace

## 使用示例

### StaticSpace

from classspace import StaticSpace

class Mathpart(StaticSpace):
    def sqrt(x):
        return x**0.5
    def square(x):
        return x**2

class Stringpart(StaticSpace):
    def isin(a, b):
        return a in b

a = Mathpart.sqrt(2)
b = Stringpart.isin('a', 'apple')
# 不能实例化：Mathpart() 会报错

### DecorateClass

from classspace import DecorateClass, withoutdec

def timer(func):
    def wrapper(*a, **k):
        import time
        start = time.time()
        res = func(*a, **k)
        print(f"耗时: {time.time()-start}")
        return res
    return wrapper

class MyClass(DecorateClass(timer)):
    def heavy():
        print("doing heavy work...")

MyClass.heavy()

### LabelEnum

from classspace import LabelEnum, classenum

class Color(LabelEnum):
    class red: pass
    class blue: pass

print(Color.red)  # <object……>

## 许可证

MIT
