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

Missing ignore_types arg when calling the method of flatten recursively #24

Open
xiaofeig opened this issue Mar 21, 2019 · 0 comments
Open

Comments

@xiaofeig
Copy link

The code has missed ignore_types arg when calling the method of flatten recursively in the example about how to flatten a nested sequence.

src/4/how_to_flatten_a_nested_sequence/example.py

from collections import Iterable

def flatten(items, ignore_types=(str, bytes)):
    for x in items:
        if isinstance(x, Iterable) and not isinstance(x, ignore_types):
            yield from flatten(x)
        else:
            yield x

The corrected code is yield from flatten(x, ignore_types).

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

1 participant