mardi 15 août 2017

Any legit way for using "if" statements and "for" loop while creating a dictionary in Python?

report['conditions'] += [{"name": cond,
                                          "biRad": br,
                                          "findings": [
                                              {"name": f,
                                               **if f == 'mass':** 
                                               "parameters": [
                                                   {
                                                        "name": iter_params_mass[0],
                                                        "value": create_rep(iter_params_mass, row, f, r)[0]

                                                   },{...}

                                               ] }
                                          ]}]

I have very strict structure for my BSON file, but instead of creating everything manually, I would like to use if statement and for loop (if possible), because I can have more than 1 pair of name-value in parameters. Any efficient way to do it? Thanks! I'm using Python 3.6.0

Aucun commentaire:

Enregistrer un commentaire