Peach :: Generators :: dictionary :: List :: Class List
[hide private]

Class List

source code


Iterates through a specified list of values. When the end of the list is reached a generator.GeneratorCompleted exceoption is raised. Last item will be returned until reset is called.

Example:

>>> list = List(None, ['1', '2', '3'])
>>> list.getValue()
1
>>> list.next()
>>> list.getValue()
2
>>> list.next()
>>> list.getValue()
3
Instance Methods [hide private]
 
__init__(self, group, list=None)
Base constructor, please call me!
source code
 
reset(self)
Called to reset the generator to its initial state.
source code
 
next(self)
Next value.
source code
string
getRawValue(self)
Return raw value w/o passing through transformer if set.
source code
list
getList(self)
Get current list of values.
source code
 
setList(self, list)
Set list of values.
source code

Inherited from generator.Generator: __iter__, getGroup, getName, getTransformer, getValue, identity, setGroup, setName, setTransformer

Static Methods [hide private]
 
unittest() source code
Class Variables [hide private]
  _list = None
  _curPos = 0
Method Details [hide private]

__init__(self, group, list=None)
(Constructor)

source code 

Base constructor, please call me!

Parameters:
  • group (Group) - Group this Generator belongs to
  • list (list) - List of values to iterate through
Overrides: generator.Generator.__init__

reset(self)

source code 

Called to reset the generator to its initial state. OVERRIDE

Overrides: generator.Generator.reset
(inherited documentation)

next(self)

source code 

Next value. OVERRIDE

From Python docs on next():

The intention of the protocol is that once an iterator's next() method raises StopIteration, it will continue to do so on subsequent calls. Implementations that do not obey this property are deemed broken. (This constraint was added in Python 2.3; in Python 2.2, various iterators are broken according to this rule.)

For Generators, please use the GeneratorCompleted exception instead of StopIteration (its a subclass).

Overrides: generator.Generator.next
(inherited documentation)

getRawValue(self)

source code 

Return raw value w/o passing through transformer if set. OVERRIDE

Returns: string
Data before transformations
Overrides: generator.Generator.getRawValue
(inherited documentation)

getList(self)

source code 

Get current list of values.

Returns: list
Current list of values

setList(self, list)

source code 

Set list of values.

Parameters:
  • list (list) - List of values