pydicom.multival.MultiValue

class pydicom.multival.MultiValue(type_constructor, iterable)

Class to hold any multi-valued DICOM value, or any list of items that are all of the same type.

This class enforces that any items added to the list are of the correct type, by calling the constructor on any items that are added. Therefore, the constructor must behave nicely if passed an object that is already its type. The constructor should raise TypeError if the item cannot be converted.

Note, however, that DS and IS types can be a blank string '' rather than an instance of their classes.

__init__(type_constructor, iterable)

Initialize the list of values

Parameters
  • type_constructor (type) – A constructor for the required type for all list items. Could be the class, or a factory function. For DICOM multi-value data elements, this will be the class or type corresponding to the VR.

  • iterable (iterable) – An iterable (e.g. list, tuple) of items to initialize the MultiValue list.

Methods

__init__(type_constructor, iterable)

Initialize the list of values

append(val)

S.append(value) – append value to the end of the sequence

clear()

count(value)

extend(values)

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value, [start, [stop]])

Raises ValueError if the value is not present.

insert(position, val)

S.insert(index, value) – insert value before index

pop([index])

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) – remove first occurrence of value.

reverse()

S.reverse() – reverse IN PLACE

sort([key, reverse])

append(val)

S.append(value) – append value to the end of the sequence

insert(position, val)

S.insert(index, value) – insert value before index