Pythonic list to bitflag mapping

Ramon Felciano felciano at ingenuity.com
Thu Dec 2 18:09:31 EST 2004


> Or can be used directly as an integer index to get a character
> 
>  >>> ['01'[x in a] for x in xrange(10)]
>  ['0', '0', '0', '1', '1', '0', '1', '0', '0', '0']
> 
Very cool -- this does the trick nicely and seems quite extensible,
now that I get the basic idiom.

Belated thanks for the quick replies on this one!

Ramon



More information about the Python-list mailing list