[Tutor] Preference to Bitwise operators in comparison to Logical operators

Alan Gauld alan.gauld at yahoo.co.uk
Fri Sep 11 04:17:56 EDT 2020


On 11/09/2020 01:47, boB Stepp wrote:

> Your mention of bitmasks brought to mind the curses module.  These are
> used in curses for setting properties.  Are there any practical uses of
> "bit twiddling" in the context of curses?

It's all bit twiddling with curses properties, you just don't
see the bits because everything has predefined constants.
But if you were perverse you could just pass binary
integers instead. If you print the constants you'll
see the integer values.

But I can't think of anything useful you could do by
manipulating the masks with shifting or xor-ing them.
Maybe flipping between two attribute styles would work,
but it's just as easy to apply two defined bitmasks.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list