Skip to content

Instantly share code, notes, and snippets.

@gidgid
Last active February 5, 2021 11:46
Show Gist options
  • Save gidgid/fdef8b58edac9946f8bdac2af0b14d28 to your computer and use it in GitHub Desktop.
Save gidgid/fdef8b58edac9946f8bdac2af0b14d28 to your computer and use it in GitHub Desktop.
Examples of how more_itertools always_iterable works
from more_itertools import always_iterable
always_iterable([1,3, 5]) # => <list_iterator at 0x107deca30>
list(always_iterable([1,3, 5])) # => [1, 3, 5]
list(always_iterable({1,3, 5})) # => [1, 3, 5] (works on all iterables)
list(always_iterable(42)) # => [42]
list(always_iterable([])) # => []
list(always_iterable(None)) # => []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment