mirror of https://github.com/iKarith/cppo-ng.git
Correct typing and docstring on seqsplit
Type hinting in Python is just that: Hinting. Which means if you do it wrong, as long as the syntax is right, Python itself will just let you do it. Python is intended to be a duck-typed language, so you're really just documenting you intent/expectations. The feature is somewhat new, and its conventions are not completely understood by certain tools that encounter it. This apparently applies to myself as a developer trying to use it. ;)
This commit is contained in:
parent
d0a8dc2584
commit
3eb8d7cade
|
@ -16,10 +16,10 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
from typing import Sequence
|
||||
from typing import Sequence, Iterator
|
||||
|
||||
def seqsplit(seq: Sequence, num: int) -> Sequence:
|
||||
"""split Sequence into smaller Sequences of size 'num'"""
|
||||
def seqsplit(seq: Sequence, num: int) -> Iterator[Sequence]:
|
||||
"""Returns a generator that yields num-sized slices of seq"""
|
||||
for i in range(0, len(seq), num):
|
||||
yield seq[i:i + num]
|
||||
|
||||
|
|
Loading…
Reference in New Issue