python remove, not working
Go to solution
Solved by fizzlesticks,
1 hour ago, vorticalbox said:So how come I could append the working ones to a new list?
Pool.map returns a list of all the return values from the function.
So for example, to remove all the odd numbers in a list you can do:
from multiprocessing import Pool
from itertools import compress
def f(s):
return s % 2 == 0
if __name__ == '__main__':
r = [1,2,3,4,5,6]
print(r)
with Pool(5) as p:
ret = p.map(f, r)
print(ret)
r = list(compress(r, ret))
print(r)
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now