# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/.
>>> split_evenly(1, 2)
Traceback (most recent call last):
...
ChunkingError: Number of chunks is greater than number
""" if n < chunks: raise ChunkingError("Number of chunks is greater than number") if n % chunks == 0: # Either we can evenly split or only 1 chunk left return [n // chunks] * chunks # otherwise the current chunk should be a bit larger
max_size = n // chunks + 1 return [max_size] + split_evenly(n - max_size, chunks - 1)
def chunkify(things, this_chunk, chunks): if this_chunk > chunks: raise ChunkingError("this_chunk is greater than total chunks")
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.