pydicom.config.INVALID_KEY_BEHAVIOR = 'WARN'

Control the behavior when invalid keys are used with __contains__() (e.g. 'invalid' in ds).

New in version 2.1.

Invalid keys are objects that cannot be converted to a BaseTag, such as unknown element keywords or invalid element tags like 0x100100010.

If "WARN" (default), then warn when an invalid key is used, if "RAISE" then raise a ValueError exception. If "IGNORE" then neither warn nor raise.


>>> from pydicom import config
>>> ds = Dataset()
>>> 'PatientName' in ds  # OK
>>> 'PatientsName' in ds
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../pydicom/", line 494, in __contains__
    raise ValueError(msg) from exc
ValueError: Invalid value used with the 'in' operator: must be an
element tag as a 2-tuple or int, or an element keyword