News for hackers. Stuff that matters.
Re:Namedtuple in a Post-Dataclasses World by bionhoward on Wednesday July 21, 2021 @12:28PM (#27908366)
Along this line of reasoning I learned to love Pydantic which can make it a breeze to parse and coerce environment variables to the correct types: https://pydantic-docs.helpmanual.io/usage/settings/

You can make an env.py and override module __getattr__ and then import environment variables just like they're regular Python objects (even booleans, floats, collections, etc, despite .env files being string only

Huge force multiplier for ML cuz then you can do hyperparameter optimization just by passing different environment variables in an outer loop (even inside your infrastructure as code)

Edit: you can make these classes immutable too: https://pydantic-docs.helpmanual.io/usage/models/#faux-immut...

Re:Namedtuple in a Post-Dataclasses World by ElevenPhonons on Wednesday July 21, 2021 @03:29PM (#27910938)
You can also create CLI tools that can load partial or full "presets" defined in JSON.

https://github.com/mpkocher/pydantic-cli

Re:Namedtuple in a Post-Dataclasses World by jkrubin on Wednesday July 21, 2021 @03:21PM (#27910835)
Pydantic is an incredible lib. I use it for so many different things on top of misc parsing.