Iteration on Lea instances
Issue #92
resolved
It is currently not possible to iterate on a Lea instance.
list(my_lea_instance)
# -> LeaError: cannot iterate on a Lea instance
for x in my_lea_instance:
…
# -> LeaError: cannot iterate on a Lea instance
Also, it is not possible to call len
function (raises TypeError
exception).
OK... These are prudent options, unless a clear semantic is defined.
Now, since Lea supports slicing, it could be sensible to define iteration so as to yield my_lea_instance[0]
, my_lea_instance[1]
, …
Because this is done by building new instances obtained by slicing inner values, this is not meaningful on all Lea instances. This requires that the instance are subscriptable, and has a well-defined length. Two Lea subclasses could meet these requirements:
- Clea instance, resulting from a joint of N Lea instances: the
len
anditer
functions shall work, the latter simply yielding these N instances; - Alea instance: one shall verify that all inner values have same length; if this is the case, the
len
anditer
functions shall work.
Comments (2)
-
reporter -
reporter - changed status to resolved
- Log in to comment
Implement len and iter dunder methods (refs
#92)→ <<cset 1d04d43d2451>>