Skip to content

Ability to not throw exceptions for un-declared Dataset attributes? #1357

Answered by darcymason
richard-moss asked this question in Q&A
Discussion options

You must be logged in to vote

Is there a more elegant way of handling this? (meaning less verbage, more concise, cleaner,...)

There is in, shown just below, or get further below:

if 'AccessionNumber' in dcm:
    ....

Would it be reasonable to have a config or ability in Dataset's to have the default lookup of a un-declared attribute return None if not declared?

That's the purpose of the get method, e.g.:

dcm.get("AccessionNumber")

get returns None by default, but you could supply an alternate value

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by mrbean-bremen
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@richard-moss
Comment options

@darcymason
Comment options

@richard-moss
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1356 on April 16, 2021 19:45.