Thomas Heller got in touch with me, and pointed out that my getMultipleWindowValues() function (see part 3) does A Very Bad Thing. It mutates a Python string. These are supposed to be immutable in Python. This didn't break anything of mine, or hasn't yet, but it certainly could. If, for example, a string being used as a key in a dictionary mutated, who knows what would happen? BANG!
def getMultipleWindowValues(hwnd, getCountMessage, getValueMessage):
bufferlength = struct.pack('i', 255)
count = win32gui.SendMessage(hwnd, getCountMessage, 0, 0)
for itemIndex in range(count):
value = array.array('c', bufferlength + str().ljust(253))
valueLength = win32gui.SendMessage(hwnd, getValueMessage, itemIndex, value)
Update: See the whole series: Driving win32 GUIs with Python, part 1, Driving win32 GUIs with Python, part 2, Driving win32 GUIs with Python, part 3, Driving win32 GUIs with Python, part 4 and 7 hours, one line of code.Posted to Python by Simon Brunning at March 31, 2003 01:43 PM