hl7apy
hl7apy copied to clipboard
Support default value in getattr
It would be great to be able to write:
patient_name = message.ORM_O01_PATIENT.PID.PATIENT_NAME
suffix = getattr(patient_name, 'PROFESSIONAL_SUFFIX', '')
rather than having to use hasattr
or handle an exception if the attribute is not present.
The root cause seems to be that Element
uses return self.children.get(name)
in __getattr__
and this throws ChildNotValid
exception, which is not an AttributeError
.
Hi Ian, you're right. We'll try to put that feature in the next release. Thank you, Vittorio