Pydantic to Python conversion #9492
Unanswered
maxschulz-COL
asked this question in
Question
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a clever way to export an instantiated pydantic model into a string representation that is equivalent to python code that would be needed to instantiate that model.
Basically
repr(Model)
pretty much does the job, but it lacks the beautiful options likeexclude_unset
from sayModel.dict()
, which would ensure the most "apt" representation of what someone would write out in python to create the object.Note that I am using pydantic V1 - but happy to get suggestions for either version.
Many thanks for any clever idea! 🙏
Beta Was this translation helpful? Give feedback.
All reactions