Re: Exclude 'None' from list comprehension of dicts

2022-08-16 Thread Antoon Pardon
Op 16/08/2022 om 00:20 schreef dn: On 16/08/2022 00.56, Antoon Pardon wrote: Op 5/08/2022 om 07:50 schreef Loris Bennett: Antoon Pardon   writes: Op 4/08/2022 om 13:51 schreef Loris Bennett: Hi, I am constructing a list of dictionaries via the following list comprehension:     data = [g

Re: Exclude 'None' from list comprehension of dicts

2022-08-15 Thread dn
On 16/08/2022 00.56, Antoon Pardon wrote: > Op 5/08/2022 om 07:50 schreef Loris Bennett: >> Antoon Pardon  writes: >> >>> Op 4/08/2022 om 13:51 schreef Loris Bennett: Hi, I am constructing a list of dictionaries via the following list comprehension:     data = [get_job

Re: Exclude 'None' from list comprehension of dicts

2022-08-15 Thread Antoon Pardon
Op 5/08/2022 om 07:50 schreef Loris Bennett: Antoon Pardon writes: Op 4/08/2022 om 13:51 schreef Loris Bennett: 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_effici

RE: Exclude 'None' from list comprehension of dicts

2022-08-05 Thread avi.e.gross
: Exclude 'None' from list comprehension of dicts Antoon Pardon writes: > Op 4/08/2022 om 13:51 schreef Loris Bennett: >> Hi, >> >> I am constructing a list of dictionaries via the following list >> comprehension: >> >>data = [get_job_efficiency_

Re: Exclude 'None' from list comprehension of dicts

2022-08-05 Thread Loris Bennett
Antoon Pardon writes: > Op 4/08/2022 om 13:51 schreef Loris Bennett: >> 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) >> >>

Re: Exclude 'None' from list comprehension of dicts

2022-08-04 Thread Weatherby,Gerard
Or: data = [d for d in [get_job_efficiency_dict(job_id) for job_id in job_ids] if d is not None] or for job_id in job_ids: if (d := get_job_efficiency_dict(job_id)) is not None: data.append(d) Personally, I’d got with the latter in my own code. — Gerard Weatherby | Application Arch

Re: Exclude 'None' from list comprehension of dicts

2022-08-04 Thread MRAB
On 2022-08-04 12:51, Loris Bennett wrote: 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 th

Re: Exclude 'None' from list comprehension of dicts

2022-08-04 Thread Antoon Pardon
Op 4/08/2022 om 13:51 schreef Loris Bennett: 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

Re: Exclude 'None' from list comprehension of dicts

2022-08-04 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>data = [get_job_efficiency_dict(job_id) for job_id in job_ids] > ... >>filtered_data = list(filter(None, data)) > > You could have "get_job_efficiency_dict" return an iterable > that yields either zero dictionaries or on