[python-win32] Threading Issue
Jim Vickroy
Jim.Vickroy at noaa.gov
Tue Jul 3 21:12:01 CEST 2007
James Matthews wrote:
> So i need to make the list a global variable
It could be but that is not necessary. The list is simply a variable
known to the program unit that creates the threading.Thread(...) instance.
>
> On 7/3/07, *Jim Vickroy* <Jim.Vickroy at noaa.gov
> <mailto:Jim.Vickroy at noaa.gov>> wrote:
>
> James Matthews wrote:
>> Dear List.
>>
>> When spawning a thread using the threading module syntax
>> new_thread = threading.Thread(target=function_returning_a_list)
>> How can i get the list that this function is supposed to return.
>>
>> Thanks
>> James
>>
>>
>> --
>> http://www.goldwatches.com/watches.asp?Brand=14
>> http://www.jewelerslounge.com
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Python-win32 mailing list
>> Python-win32 at python.org <mailto:Python-win32 at python.org>
>> http://mail.python.org/mailman/listinfo/python-win32
>>
> Hello James,
>
> There is no direct way to do what you want. Here is an example of
> how to indirectly do it:
>
> >>> import threading
> >>> def foo(result):
> ... [result.append(i) for i in range(4)]
> ...
> >>> result = list()
> >>> thread = threading.Thread(target=foo, args=(result,))
> >>> thread.start()
> >>> result
> [0, 1, 2, 3]
> >>>
>
>
>
>
> --
> http://www.goldwatches.com/watches.asp?Brand=14
> http://www.jewelerslounge.com <http://www.jewelerslounge.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070703/eb2ef61e/attachment.htm
More information about the Python-win32
mailing list