Hi,

I am constructing a list of dictionaries via the following list
comprehension:

  data = [get_job_efficiency_dict(job_id) for job_id in job_ids]

However,

  get_job_efficiency_dict(job_id)

uses 'subprocess.Popen' to run an external program and this can fail.
In this case, the dict should just be omitted from 'data'.

I can have 'get_job_efficiency_dict' return 'None' and then run

  filtered_data = list(filter(None, data))

but is there a more elegant way?

Cheers,

Loris

-- 
This signature is currently under construction.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to