Skip to content

Instantly share code, notes, and snippets.

@dnene
Created October 31, 2011 16:40
Show Gist options
  • Save dnene/1327932 to your computer and use it in GitHub Desktop.
Save dnene/1327932 to your computer and use it in GitHub Desktop.
grouping by truth values
import itertools
print dict((key,list(iter)) for key,iter in itertools.groupby(sorted([True, False, -1, 0, 1, 2, None, object(), [], [object()], {}, {'foo': object()}],key = bool),bool))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment