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
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
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
: 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_
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)
>>
>>
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
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
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
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