"MM" wrote: > What is the best structure/way to create an array of bits (actually > true/false flags) of an > arbitrary length ranging from about 20 upto about 500. Speed of access more > of an issue than > compactness. > > eg: > [0] 0 > [1] 0 > [2] 1 > [3] 0 > [4] 1 > ... > [n] 0 > etc.
if you need a list of flags, use a list of flags: [False] * 500 (compared to a bit array, you'll waste a whopping 31 bits per flag, but unless you plan to use tens of thousands of lists, that shouldn't be much of a problem) </F> -- http://mail.python.org/mailman/listinfo/python-list