Capslock and Python Question

Hello All,

I was looking for a solution for enabling/disabling the Capslock from the command line and came across some Python code for doing just that...
Well, in this case the code was written to ONLY turn-off Capslock but I assume there has to be a way to turn it on too.

Site where I found the code: xmodmap - How do I turn off Caps Lock (the lock, not the key) by command line? - Ask Ubuntu

Let me start by saying that this is the 1st time I've ever used Python, so I'm a noob with that... But if I just copy/paste the code from the link above
and just execute it from the Command Line, it DOES turn off the Capslock as it's supposed to. But if I enter what I thought would be the code to turn
back on, I get an error.

Code:
*This code does work to turn OFF Capslock...

#!/usr/bin/env python
from ctypes import *
X11 = cdll.LoadLibrary("libX11.so.6")
display = X11.XOpenDisplay(None) X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0))
X11.XCloseDisplay(display)

And from the Manpage for XkbLockModifiers (*xkblockmodifiers(3) - Linux man page) I can see that the last element in the function call is what
you want to change the value to (*i.e. the "unsigned int value").

xkblockmodifiers(3) - Linux man page

Bool XkbLockModifiers (Display *display, unsigned int device_spec, unsigned int affect, unsigned int values);
        1 => lock, 0 => unlock; only for modifiers selected by affect 

So I changed "value" variable from "0" to "1", and I get the following error:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  144 (XKEYBOARD)
  Minor opcode of failed request:  5 (XkbLatchLockState)
  Serial number of failed request:  7
  Current serial number in output stream:  9

Any idea why this would throw an error when assigning to "1" (*i.e. ON) but would work correctly when assigning to "0" (*i.e. OFF)..?
I've tried the "xset led named 'Caps Lock' " Command and the "setleds +caps < /dev/console" command, but neither do anything to the Capslock...

If anyone has any ideas, please feel free. Any thoughts or suggestions would be much appreciated!

Thanks in Advance,
Matt