Skip to content

Instantly share code, notes, and snippets.

@SamyBencherif
Last active January 16, 2018 03:15
Show Gist options
  • Save SamyBencherif/91c69521cdf9900122546727544c749e to your computer and use it in GitHub Desktop.
Save SamyBencherif/91c69521cdf9900122546727544c749e to your computer and use it in GitHub Desktop.
Better Binary Output Python (from a trashy one-liner)
bbin = lambda x: ''.join([' '+x if i%4==0 and i!=0 else x for i,x in enumerate(bin(x)[2:].zfill((len(bin(x))-2-1)/4*4+4))])
print(bbin(8039)) #0001 1111 0110 0111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment