Magic of class-to-str
Project description
cls-str
Convert Python classes to strings and back. Useful for serialization, configuration files, and message passing.
Installation
pip install cls-str
Quick Start
Basic Usage
from cls_str import cls_to_str, str_to_cls
# Convert class to string
from http.server import SimpleHTTPRequestHandler
class_path = cls_to_str(SimpleHTTPRequestHandler)
print(class_path)
# Output: "http.server.SimpleHTTPRequestHandler"
# Convert string back to class
restored_class = str_to_cls(class_path)
assert restored_class is SimpleHTTPRequestHandler
Nested Classes
class Outer:
class Inner:
pass
# Works with nested classes too
path = cls_to_str(Outer.Inner)
print(path)
# Output: "your_module.Outer.Inner"
loaded_class = str_to_cls(path)
assert loaded_class is Outer.Inner
License
MIT License
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
cls_str-0.1.1.tar.gz
(2.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cls_str-0.1.1.tar.gz.
File metadata
- Download URL: cls_str-0.1.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1df00e829fe918950d5348d2e0870bb7f48a87142e9f9f167777d8ad0754e5b2
|
|
| MD5 |
f2b29922beffe413381806e3fed2e088
|
|
| BLAKE2b-256 |
433f6b370db65fdca7a62342435f31d76a51784fa2c919134e6a2d34e64606f2
|
File details
Details for the file cls_str-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cls_str-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.14 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65e183868f1577eb99839b720efba4042641cc880d1b5ffd93bb873db60b9438
|
|
| MD5 |
6f21c3fdc9d41e45155632a2adafab6d
|
|
| BLAKE2b-256 |
656f379f25ec52d0219b7f5c12b7170f6c115d300e06bbaef72fe322f7815004
|