Return an iterator over an arbitrarily nested sequence.
Parameters : |
|
---|---|
Returns : |
|
Examples
>>> for a in cf.flat([1, [2, [3, 4]]]):
... print a,
1 2 3 4
>>> for a in cf.flat(['a', ['bc', ['def', 'ghij']]]):
... print a, ' ',
a bc def ghij
>>> for a in cf.flat(2004):
... print a
2004
>>> for a in cf.flat('abcdefghij'):
... print a,
abcdefghij
>>> f
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
>>> for a in cf.flat(f):
... print a
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
>>> for a in cf.flat([f, [f, [f, f]]]):
... print a
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>
>>> fl = cf.FieldList(cf.flat([f, [f, [f, f]]])
>>> fl
[<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>,
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>,
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>,
<CF Field: eastward_wind(air_pressure(5), latitude(110), longitude(106)) m s-1>]