On 5/25/05, James Carroll <[EMAIL PROTECTED]> wrote: > I'm trying to call functions on an automation object, and I've run > makepy to generate a wrapper, and 99% of the calls I make on the > wrapper work great. > > my question is: Is my [''] * 10 as close as I can come to a variant > array of pre-allocated empty strings? > > I'm trying to call a function called EnumerateCameras > > m.ShowLiveWindow(True) <--- this works > cams = [''] * 10 > m.EnumerateCameras(cams) > <CRASH!>
Python strings are immutable. If EnumerateCameras is trying to modify them, who knows *what* might happen... > Is my [''] * 10 as close as I can come to a variant array of > pre-allocated empty strings? Have you looked at ctypes? (<http://starship.python.net/crew/theller/ctypes/>.) It has a create_string_buffer function for creating mutable memory blocks, so you might do somethign like: cams = list(ctypes.create_string_buffer(256) for _ in range(10)) 256 is a wild guess, obviously. ;-) -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list