beda-software / fhir-py

FHIR Client for python
MIT License
174 stars 32 forks source link

Accessing invalid field returns key error and not attribute error #66

Closed BSVogler closed 3 years ago

BSVogler commented 3 years ago

When you have an FHIR resource object and try to access a field, which does no exists you get a KeyError. Python standard is AttributeError.

This causes hasattr(fhirresource, "field") to return an error instead of False, because internally it catches an attribute error and not a key error.

mkizesov commented 3 years ago

Just to clarify. You prefer to access resource's fields as attributes like this patient.gender, do you?

BSVogler commented 3 years ago

It is supported by the library so I might use it.

ir4y commented 3 years ago

Close since PR with the fix was merged.