Skip to content

Instantly share code, notes, and snippets.

@dstufft
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save dstufft/9821953 to your computer and use it in GitHub Desktop.

Select an option

Save dstufft/9821953 to your computer and use it in GitHub Desktop.
# thing = Can be a bytes instance, or something that yields bytes instances
for x in thing:
if isinstance(x, int):
x = bytes((x,))
# Do the actual work
pass
for x in map(lambda x: bytes((x,)) if isinstance(x, int) else x, thing):
# Do the actual work
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment