diff options
author | Bryan Bishop <kanzure@gmail.com> | 2013-09-01 16:31:55 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2013-09-01 16:31:55 -0500 |
commit | acf23488e8c1ecb52ede8442346e4df2ea39f4d8 (patch) | |
tree | fcf99e9d62d1d3176d77d23b5e911527abd7340b /pokemontools/helpers.py | |
parent | 5385ccd6d7fbc47f82df6d5ff4045f297ac71ac0 (diff) |
better docstrings in helpers.py
Diffstat (limited to 'pokemontools/helpers.py')
-rw-r--r-- | pokemontools/helpers.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/pokemontools/helpers.py b/pokemontools/helpers.py index 232a632..2ecb073 100644 --- a/pokemontools/helpers.py +++ b/pokemontools/helpers.py @@ -4,18 +4,25 @@ Generic functions that should be reusable anywhere in pokemontools. import os def index(seq, f): - """return the index of the first item in seq - where f(item) == True.""" + """ + return the index of the first item in seq + where f(item) == True. + """ return next((i for i in xrange(len(seq)) if f(seq[i])), None) def grouper(some_list, count=2): - """splits a list into sublists + """ + splits a list into sublists + given: [1, 2, 3, 4] - returns: [[1, 2], [3, 4]]""" + returns: [[1, 2], [3, 4]] + """ return [some_list[i:i+count] for i in range(0, len(some_list), count)] def flattener(x): - "flattens a list of sublists into just one list (generator)" + """ + flattens a list of sublists into just one list (generator) + """ try: it = iter(x) except TypeError: @@ -26,7 +33,9 @@ def flattener(x): yield j def flatten(x): - "flattens a list of sublists into just one list" + """ + flattens a list of sublists into just one list + """ return list(flattener(x)) def mkdir_p(path): |