4 ms·
> Though neither python nor rust have such a nice `.split(None)` built in. Sorry, I'm not sure I understand what `.split(None)` would do? My initial instinct i
by papercrane 1y ago
> Though neither python nor rust have such a nice `.split(None)` built in.
Sorry, I'm not sure I understand what `.split(None)` would do? My initial instinct is that would would return each character. i.e. `.chars()` in Rust or `list(s)` in Python.
- rspencer 1y agoIt was intended to split a list of `int|None` into its non-none stretches. Much like how `string.split('x')` splits a string by matching the character 'x'
- papercrane 1y agoGotcha! In python there is a `split_at` function for this in the more-itertools package, but I don't think there is a concise way to do it in the stdlib.
- bear8642 1y ago>Sorry, I'm not sure I understand what `.split(None)` would do? Reading the docs [0] it seems `.split(None)` returns an array of the indivual characters without whitespace - so something like [c in list(s) if not whitespace(c)] [0] https://docs.python.org/3.3/library/stdtypes.html?highlight=split#str.split https://docs.python.org/3.3/library/stdtypes.html?highlight=...