Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split_before confuse me #304

Closed
ghost opened this issue Jul 30, 2019 · 3 comments
Closed

split_before confuse me #304

ghost opened this issue Jul 30, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 30, 2019

The docs says split_before

Yield lists of items from iterable, where each list starts with an item where callable pred returns True

But why below returns

In [3]: list(split_before(range(1, 10), lambda n: n % 3 == 0))
Out[3]: [[1, 2], [3, 4, 5], [6, 7, 8], [9]]

Rather than returns

In [3]: list(split_before(range(1, 10), lambda n: n % 3 == 0))
Out[3]: [[3, 4, 5], [6, 7, 8], [9]]

What i`m got wrong ? Thanks in advance

@bbayles
Copy link
Collaborator

bbayles commented Jul 31, 2019

Thanks for the note. You're right; I should change the docstring to be more accurate. No items are skipped by split_before.

@ghost
Copy link
Author

ghost commented Aug 1, 2019

Thanks for your reply, it solves my question.

@ghost ghost closed this as completed Aug 1, 2019
@failable
Copy link

I've thought that list(split_before('OneTwo', lambda s: s.isupper())) will return [[''], ['O', 'n', 'e'], ['T', 'w', 'o']]...

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants