Skip to main content

StaticSpace, DecorateClass, LabelEnum - Python class utilities

Project description

classspace

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

安装

pip install classspace

使用示例

StaticSpace

from classspace import StaticSpace

class Mathpart(StaticSpace): def sqrt(x): return x0.5 def square(x): return x2

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

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

classspace-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

classspace-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file classspace-0.1.0.tar.gz.

File metadata

  • Download URL: classspace-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for classspace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 01d5486d3292b018dd7d7aad6c31d380d9c4303a6c63191d27d25da5006c07db
MD5 4e0628610f552be7801102c2b45c12e9
BLAKE2b-256 f25a66658acf06f78768d833342aa1377150c6249d7d95de043dff6a9b3324bc

See more details on using hashes here.

File details

Details for the file classspace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: classspace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for classspace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ecdcbcb5dbb1c1677fa5069d8a6e5a8d6e356577dccda92a8f30fe1ced82445
MD5 edb3751b390a2e20c1d2e6b03fd116bc
BLAKE2b-256 d0b560364fb7d75138250aa8d800c1807ef87a19a5c6ac503bb4b855813dc380

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page