Re: [Tutor] Chunking list/array data?

2019-08-22 Thread Cameron Simpson
On 21Aug2019 21:26, Sarah Hembree wrote: How do you chunk data? We came up with the below snippet. It works (with integer list data) for our needs, but it seems so clunky. def _chunks(lst: list, size: int) -> list: return [lst[x:x+size] for x in range(0, len(lst), size)] What do

Re: [Tutor] Chunking list/array data?

2019-08-22 Thread Peter Otten
Sarah Hembree wrote: > How do you chunk data? We came up with the below snippet. It works (with > integer list data) for our needs, but it seems so clunky. > > def _chunks(lst: list, size: int) -> list: > return [lst[x:x+size] for x in range(0, len(lst), size)] > > What do you do?

[Tutor] Chunking list/array data?

2019-08-22 Thread Sarah Hembree
How do you chunk data? We came up with the below snippet. It works (with integer list data) for our needs, but it seems so clunky. def _chunks(lst: list, size: int) -> list: return [lst[x:x+size] for x in range(0, len(lst), size)] What do you do? Also, what about doing this lazily

Re: [Tutor] Is nesting functions only for data hiding overkill?

2019-08-22 Thread Cameron Simpson
On 22Aug2019 00:53, James Hartley wrote: Yes, nesting functions is valuable & necessary for closures and wrapping functions for creating properties. But is nesting, simply for hiding data, a preferred solution? I have a number of member functions which are prefaced with underscores pointing

[Tutor] Is nesting functions only for data hiding overkill?

2019-08-22 Thread James Hartley
Yes, nesting functions is valuable & necessary for closures and wrapping functions for creating properties. But is nesting, simply for hiding data, a preferred solution? I have a number of member functions which are prefaced with underscores pointing out that they should not be called by client