[python-win32] Threading Issue

James Matthews nytrokiss at gmail.com
Tue Jul 3 21:08:47 CEST 2007


So i need to make the list a global variable

On 7/3/07, Jim Vickroy <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 listPython-win32 at python.orghttp://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070703/f8497565/attachment.html 


More information about the Python-win32 mailing list