cf.FieldList

class cf.FieldList(fields=None)[source]

Bases: list

An ordered sequence of fields.

Each element of a field list is a cf.Field object.

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

>>> fl = cf.FieldList()
>>> len(fl)
0
>>> f
<CF Field: air_temperaturetime(12), latitude(73), longitude(96) K>
>>> fl = cf.FieldList(f)
>>> len(fl)
1
>>> fl = cf.FieldList([f, f])
>>> len(fl)
2
>>> fl = cf.FieldList(cf.FieldList([f] * 3))
>>> len(fl)
3
>>> len(fl + fl)
6

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

Initialization

Parameters:
fields: (sequence of) cf.Field, optional

Create a new field list with these fields.

Inspection

dump A full description of each field.

Selection

select Return the fields that satisfy the given conditions.
select_field Return the unique field that satisfies the given conditions.

Comparison

equals True if two field lists are equal, False otherwise.
set_equals set equals

Miscellaneous

concatenate Join a sequence of fields together.
copy Return a deep copy.

List-like operations

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

>>> fl.count(x)

is equivalent to

>>> sum(f.equals(x) for f in fl)
append L.append(object) – append object to end
count Return number of occurrences of value
extend L.extend(iterable) – extend list by appending elements from the iterable
index Return first index of value.
insert L.insert(index, object) – insert object before index
pop Raises IndexError if list is empty or index is out of range.
reverse L.reverse() – reverse IN PLACE
sort Stable sort of the field list IN PLACE
__add__ Called to implement evaluation of f + x
__contains__ Called to implement membership test operators.
__iadd__ x.__iadd__(y) <==> x+=y
__imul__ x.__imul__(y) <==> x*=y
__getitem__ Called to implement evaluation of f[index]
__len__
__mul__ Called to implement evaluation of f * x
__setitem__ x.__setitem__(i, y) <==> x[i]=y

Special methods

__deepcopy__ Called by the copy.deepcopy standard library function.
__repr__ Called by the repr built-in function.
__str__ Called by the str built-in function.