Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Obtain objects of list separated by comma

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading