--- layout: post title: "python: marshmallow fluff..." author: mjadud tags: - cc-sa - python - metaprogramming - blog - "2020" - 2020-03 publishDate: 2020-03-20 --- So, I still like my metaprogramming tricks. It was fun. I learned things. But, I went to [PyPi](https://pypi.org/), and discovered they have a very nice search feature. [I searched for marshmallow](https://pypi.org/search/?q=marshmallow). I found... 263 projects referencing marshmallow. It's a unique enough word that I'm going to *guess* that they all interact with the `marshmallow` library in some way. A lot of them do what I was exploring. For example, [marshmallow-objects](https://github.com/sv-tools/marshmallow-objects) does *exactly* what I was doing, but better. (Well, mostly. Kinda.) Actually, it is different. You still have to define Python classes... but, you can subclass a marshmallow model that gives you serialization/deserialization without having to write a separate schema. It wouldn't let me dynamically generate the classes from a YAML file (that's a neat trick, I think), but it might be fine to write the class as code. I mean, it's easier to test the class, whereas the dynamic trickery is just that... So. Lesson learned. Or, if you prefer, a lesson I've always known, and taught my students many times: *do a search first*. Someone else has probably done it. As the old joke goes: ![asdfasdf](https://imgs.xkcd.com/comics/python.png)