Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support default value in getattr #11

Open
iatkinson opened this issue Nov 16, 2014 · 2 comments
Open

Support default value in getattr #11

iatkinson opened this issue Nov 16, 2014 · 2 comments

Comments

@iatkinson
Copy link

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.

@iatkinson
Copy link
Author

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.

@svituz
Copy link
Member

svituz commented Nov 17, 2014

Hi Ian,
you're right. We'll try to put that feature in the next release.
Thank you,
Vittorio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants