Egor Bolonev wrote:
hi all

my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)'
[snip]
threading.Thread(target = run, args = (os.path.join('c:\\', path))).start()

I believe the args argument to threading.Thread is supposed to be a sequence.


>>> import os
>>> path = 'directory'
>>> os.path.join('c:\\', path)
'c:\\directory'
>>> (os.path.join('c:\\', path))
'c:\\directory'
>>> (os.path.join('c:\\', path),)
('c:\\directory',)

I think if you change the call to look like:

threading.Thread(target=run, args=(os.path.join('c:\\', path),)).start()

or

threading.Thread(target=run, args=[os.path.join('c:\\', path)]).start()

then you should be okay. You're probably getting the 10 argument message because your string is 10 characters long and threading.Thread is treating each character in your string as an argument:

>>> def f(arg):
...     print arg
...     
>>> def g(func, args):
...     func(*args)
...
>>> g(f, 'abcdefghij')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<interactive input>", line 2, in g
TypeError: f() takes exactly 1 argument (10 given)

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to