On Sunday, October 23, 2016 at 3:44:16 PM UTC-5, Thomas Nyberg wrote: > On 10/23/2016 03:12 AM, pic8...@gmail.com wrote: > > import <span class="highlight" style="padding-left: 0px; padding-right: > > 0px;">multiprocess</span>ing as mp > > > > def bar(**kwargs): > > for a in kwargs: > > print a,kwargs[a] > > > > arguments={'name':'Joe','age':20} > > p=mp.Pool(processes=4) > > p.map(bar,**arguments) > > p.close() > > p.join() > > What are you trying to do? The map method is similar to the map built-in: > > > https://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.multiprocessing.Pool.map > https://docs.python.org/2/library/functions.html#map > > map(function, iterable, ...) > Apply function to every item of iterable and return a list of the results... > > You can't apply it to keyword arguments like this. There are some > different SO threads talking about this sort of thing: > > > http://stackoverflow.com/questions/13499824/using-python-map-function-with-keyword-arguments > > http://stackoverflow.com/questions/10212445/python-map-list-item-to-function-with-arguments > > http://stackoverflow.com/questions/16874244/python-map-and-arguments-unpacking > > Maybe those (especially the last one) are helpful. > > Cheers, > Thomas Thanks for the reply.
The code snippet given by Peter is not very clear I would like to multiprocess a function which is written in python of the form bar(**kwargs) which returns a value. This example does not return anything Would you please use my example for the map function? I appreciate your help, -- https://mail.python.org/mailman/listinfo/python-list