How to pass variable to mongo pipeline from python

i have tried the below steps:

  1. stored the below pipeline in mongo db
    [{"$match": {"_id": var_id, “date”: todaysdate}}]

  2. retrieved the pipeline from mongo using python and stored in variable as below
    pipeline= [($match: var_id), ($match: date: todasdate)]
    here pipeline is string.

collection.aggregate(pipeline) // This line throws error as aggregate accepts only list not string.

so i have used json.loads(pipeline)

again now i got error as json expects double quotes for var_id… if i use double quote for var_id , value will not get assigned…

Hope this helps …Please help here