[Tutor] The print ogre

dman dsh8290@rit.edu
Thu, 21 Feb 2002 11:23:35 -0500


On Thu, Feb 21, 2002 at 08:34:41AM -0500, Charlie Clark wrote:

| Where else does ">>" occur in Python?

Right shift.

>>> print "%x" % 0xAA   
aa
>>> print "%x" % (0xAA >> 1)
55
>>> print "%x" % (0xAA >> 2)
2a
>>> print "%x" % (0xAA >> 3)
15
>>> 

It is a bitwise operator.  aa is 10101010 in binary.  Right shift it
one place and you get 01010101 which in hex is 55.  Shift it two
places and you get 00101010 which is 2a in hex.

-D

-- 

How great is the love the Father has lavished on us,
that we should be called children of God!
        1 John 3:1