function iternb (not used yet, but it's more usefull in tree than in stash)
This commit is contained in:
parent
7ad2d03534
commit
185a6e91a2
1 changed files with 10 additions and 0 deletions
|
|
@ -87,3 +87,13 @@ def iter_fields(obj):
|
||||||
if not isinstance(attribute, types.MethodType):
|
if not isinstance(attribute, types.MethodType):
|
||||||
yield attribute_name, attribute
|
yield attribute_name, attribute
|
||||||
|
|
||||||
|
def iternb(it, nb=0):
|
||||||
|
"""
|
||||||
|
Iter 'nb' times on the generator
|
||||||
|
"""
|
||||||
|
i = 0
|
||||||
|
for v in it:
|
||||||
|
if i >= nb:
|
||||||
|
raise StopIteration()
|
||||||
|
yield v
|
||||||
|
i += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue