While I was fiddling around with scrapbook, I ended up writing a dataclass for scrap.Scrap items.
I noticed in the source that you have a comment that says:
# dataclasses would be nice here...
Scrap = namedtuple("Scrap", ["name", "data", "encoder", "display"])
Scrap.__new__.__defaults__ = (None,)
So I figured you could be interested by the implementation I made! :)
See below:
Hey there!
While I was fiddling around with scrapbook, I ended up writing a dataclass for scrap.Scrap items. I noticed in the source that you have a comment that says:
So I figured you could be interested by the implementation I made! :) See below:
keys
,__getitem__
,__len__
are for the Mapping protocol, to allow the Scrap to be converted to a dict using the**
operator ({**scrap}
)__iter__
is to support unpacking the scrapasdict
,astuple
are for convenience