*args question (correction)
Tim Chase
python.list at tim.thechases.com
Wed Mar 25 12:34:09 EDT 2009
> thread.start_new_thread(myfunc, "some string", 42)
This should have been
thread.start_new_thread(myfunc, ("some string", 42))
> because all the subsequent values after the function-handle/name
> get passed into the function when it gets called. As if the
> start_new_thread() function was defined as
>
> def start_new_thread(fn, *args, **kwargs):
> thread_magic_happens_here()
> result = fn(*args, **kwargs)
> return more_thread_magic_happens_here(result)
and this should have been
def start_new_thread(fn, args=[], kwargs={}):
thread_magic()
result = fn(*args, **kwargs)
My threading-library usage is a little rusty, so I forgot those
were literal parameters, not args/kwargs that became more
idiomatic in other code authored later.
-tkc
More information about the Python-list
mailing list