Skip to content

Is there a functional difference using __init__() and parse_obj() for creating a resource from a dictionary #113

Answered by axelv
df65 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @df65,

fhir.resources is built on top of pydantic and I think your question is mainly about how pydantic models work.

This page probably answers your question: https://docs.pydantic.dev/usage/models/#helper-functions

parse_obj: this is very similar to the init method of the model, except it takes a dict rather than keyword arguments. If the object passed is not a dict a ValidationError will be raised.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@df65
Comment options

Answer selected by nazrulworld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants