[Tutor] I don't quite understand bitwise

nathan tech nathan-tech at hotmail.com
Tue Dec 15 14:11:21 EST 2020


Hi mailing list,


So I'm working on a project that, as part of this project has a function 
called self.RegisterHotKey9arg1, arg2, arg3)

It's wx python for context, but I don't think that is relevant.

An example of this is:

self.RegisterHotKey(self.kid6, win32con.MOD_ALT|win32con.MOD_SHIFT, 0x46)


What I wanted to do was make it so that the second argument could be 
anything. I was sort of treating arg2 as a list, and so I'd do something 
like:

l=["shift","windows","alt"]

bit=None

for x in l:

  bit=bit+x+|


So I started to research how the x|y format works and came across 
bitwise operators which is apparrently what is meant when x|y|z is used.

But to me they look like ints/

I am just... Completely lost on how this eeven works.


Thanks in advance.

Nathan (the lost python)



More information about the Tutor mailing list