cf.ConstructList


class cf.ConstructList(constructs=None)[source]

An ordered sequence of constructs.

The elements of the list are construct of the same type.

The list supports the python list-like operations (such as indexing and methods like append).

>>> fl = cf.ConstructList()
>>> len(fl)
0
>>> fl = cf.FieldList(f)
>>> len(fl)
1
>>> fl = cf.FieldList([f, g])
>>> len(fl)
2
>>> fl = cf.FieldList(cf.FieldList([f] * 3))
>>> len(fl)
3
>>> len(fl + fl)
6

Such methods provide functionality similar to that of a built-in list. The main difference is that when an element needs to be assessed for equality its equals method is used, rather than the == operator.

Initialisation

Parameters:
constructs: (sequence of) constructs

Create a new list with these constructs.

Methods

Methods

append

Append object to the end of the list.

clear

Remove all items from list.

close

Close all files referenced by each construct in the list.

copy

Return a deep copy.

count

Return number of occurrences of value.

equals

Whether two lists are the same.

extend

Extend list by appending elements from the iterable.

index

Return first index of value.

insert

Insert object before index.

pop

Remove and return item at index (default last).

remove

Remove first occurrence of value.

reverse

Reverse IN PLACE.

select

Alias of cf.ConstructList.select_by_identity.

select_by_identity

Select list elements constructs by identity.

sort

Sort of the list in place.