Home > database >  Obtain objects of list separated by comma
Obtain objects of list separated by comma

Time:04-01

Imaging I have this:

my_list = [{"a": 1, "b": 2}, {"a": 2, "b": 3}]

And I need to obtain only:

{"a": 1, "b": 2}, {"a": 2, "b": 3}

It will be passed into another function and that function does not accept Tuples nor Lists, only Dicts separated by comma.

_ = my_super_function_that_only_accepts_dicts_separated_by_comma(
  {"a": 1, "b": 2}, 
  {"a": 2, "b": 3},
)

CodePudding user response:

Sounds like this would be met by a straight unpack action - put a star in front, *my_list. See for example how print works.

  • Related