Skip to content

Instantly share code, notes, and snippets.

@pr4v33n
Created July 27, 2011 09:24
Show Gist options
  • Save pr4v33n/1108999 to your computer and use it in GitHub Desktop.
Save pr4v33n/1108999 to your computer and use it in GitHub Desktop.
generator
mposts = ((p.id, posts[i+1] if (i+1) != len(posts) else None) for i, p in enumerate(posts) if p.id == post.id)
for (id, next_post) in mposts:
print('Matched post id:', id)
print('Next post id:', next_post.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment