python: marshmallow fluff...

So, I still like my metaprogramming tricks. It was fun. I learned things.

But, I went to PyPi, and discovered they have a very nice search feature. I searched for 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 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:

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.