Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looping a dictionary
The first line creates an empty dict and assigns it to the name job_args.

The third line is a list comprehension, a compact way of gathering the output of a looping construct in a list. The line could be "unrolled" and replaces something like this:

temp_list = []
for arg_str in args.job_args:
job_args_tuples = temp_list
The fourth line is similar, but it is a dict comprehension instead of a list comprehension.

temp_dict = {}
for a in job_args_tuples:
    temp_dict[a[0]] = a[1]
job_args = temp_dict
harmans14 likes this post

Messages In This Thread
looping a dictionary - by harmans14 - Apr-11-2021, 07:15 PM
RE: looping a dictionary - by bowlofred - Apr-11-2021, 08:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  making list in looping a dictionary glennford49 9 1,623 Jun-25-2020, 03:23 PM
Last Post: ndc85430
  not not working looping through a dictionary rtbr17 2 1,273 Oct-04-2018, 01:37 PM
Last Post: rtbr17
  Looping through dictionary and comparing values with elements of a separate list. Mr_Keystrokes 5 2,052 Jun-22-2018, 03:08 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020