News for hackers. Stuff that matters.
Re:Working with Binary Data in Python by robzyb on Monday December 07, 2015 @05:43AM (#10688676)
This is a good article, but what I've been struggling with recently is dealing with literal binary data in Python.

What I mean by that is I literally have data stored in memory, and I want to deal with it in arbitrary groups of bits.

Sometimes 1 bit, sometimes 7 bits, rarely 13 bits.

My Google's haven't turned up much precedent.

</off topic complaint>

Re:Working with Binary Data in Python by RazerM on Monday December 07, 2015 @05:49AM (#10688686)
Have you tried bitarray[1]?

[1]: https://pypi.python.org/pypi/bitarray

Re:Working with Binary Data in Python by robzyb on Monday December 07, 2015 @06:44AM (#10688819)
It was that easy? Man. Looking forward to giving these a shot...
Re:Working with Binary Data in Python by tonyarkles on Monday December 07, 2015 @03:57PM (#10692635)
I've used it quite heavily to parse data that comes in 85- and 1275-bit chunks and it works awesome.

Edit: sorry, it was bitstring, not bitarray. bitstring.BitArray :).

Re:Working with Binary Data in Python by toyg on Monday December 07, 2015 @09:11AM (#10689490)
Obligatory XKCD: https://xkcd.com/353/
Re:Working with Binary Data in Python by _yy on Monday December 07, 2015 @11:47AM (#10690572)
+1 from me. Excellent library
Re:Working with Binary Data in Python by switch007 on Monday December 07, 2015 @05:56AM (#10688701)
Re:Working with Binary Data in Python by robzyb on Monday December 07, 2015 @06:44AM (#10688818)
Why couldn't I figure this out by myself?! Thanks!
Re:Working with Binary Data in Python by ddorian43 on Monday December 07, 2015 @03:02PM (#10692229)