D
D
dr_mamaev2018-05-28 08:28:20
Python
dr_mamaev, 2018-05-28 08:28:20

How to pass named arguments in Python?

There is a code

from threading import Thread
def a(b=None,c=None):
  if c==True and b==None:
    print('True')
Thread(target = a, args=(c=True)).start()

It should start the parallel execution of the function "a" with only the nominal argument "c", that is, the argument "b" should be passed and should not be touched in any way. But I did something wrong. How to correctly pass named arguments through "Thread"?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dr_mamaev, 2018-05-28
@dr_mamaev

Thanks, figured it out
from threading import Thread
def a(b=None,c=None):
if c==True and b==None:
print('True')
Thread(target = a, kwargs={'c':True }).start()

A
Alexander, 2018-05-28
@sanya84

It can be so.

from threading import Thread
def a(b=None,c=None):
  if c==True and b==None:
    print('True')
Thread(target=a, args=(None, True)).start()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question