i like struct library but it is designed for c objects and it doesn’t use classes.
i wonder if it is possible to make a class and decorate it using @ such that size of it’s attributes is fixed and determined by user unlike normal int or str
without having to convert them to bytes or using struct.pack
i don’t want to fill my code with boilerplate just for this simple feature. maybe if i could determine maximum size for int and str
something like this could be useful
from structclasses import structclass, sized
@structclass
class User:
name = sized(str, max_size=64)
age = sized(int, max_size=4)