pydicom.sequence.Sequence

class pydicom.sequence.Sequence(iterable: Iterable[Dataset] | None = None)[source]

Class to hold multiple Dataset in a list.

This class is derived from MultiValue and as such enforces that all items added to the list are Dataset instances. In order to do this, a validator is substituted for type_constructor when constructing the MultiValue super class.

__init__(iterable: Iterable[Dataset] | None = None) None[source]

Initialize a list of Dataset.

Parameters:

iterable (list-like of dataset.Dataset, optional) – An iterable object (e.g. list, tuple) containing Dataset. If not used then an empty Sequence is generated.

Methods

__init__([iterable])

Initialize a list of Dataset.

append(val)

Append a Dataset to the sequence.

clear()

count(value)

extend(val)

Extend the Sequence using an iterable of Dataset instances.

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

Raises ValueError if the value is not present.

insert(position, val)

Insert a Dataset into the sequence.

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(*args, **kwargs)

Attributes

parent

Return a weak reference to the parent Dataset

parent_dataset

Return a weak reference to the parent Dataset.

append(val: Dataset) None[source]

Append a Dataset to the sequence.

extend(val: Iterable[Dataset]) None[source]

Extend the Sequence using an iterable of Dataset instances.

insert(position: int, val: Dataset) None[source]

Insert a Dataset into the sequence.

property parent: weakref.ReferenceType[Dataset] | None

Return a weak reference to the parent Dataset

Deprecated since version 2.4.

property parent_dataset: weakref.ReferenceType[Dataset] | None

Return a weak reference to the parent Dataset.

New in version 2.4: Returned value is a weak reference to the parent Dataset.