[Tutor] operators >> and &

Steve Willoughby steve at alchemy.com
Sun Feb 14 10:33:56 CET 2010

On Sun, Feb 14, 2010 at 09:16:18AM -0000, Alan Gauld wrote:
> But ths is not simple integer arithmetic it is bit m,anippulation. 
> You can use bit manipulation to fake arithmetic but they are 
> fundamentally different operations and may not always 
> produce the same results depending on how the designer 
> built it!

And this brings us back to one of Python's philosophical points.
State clearly and explicitly what you mean to be doing.  If you
are doing bit manipulation, use bit manipulation operators.  All
the valid points above in this thread aside, it will make maintain-
ing your code easier in the future if it's very clear what you
intended the code to accomplish, and how.

Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.

More information about the Tutor mailing list