How to pass variable to mongo pipeline from python

If var_id is a python variable, then you just use it as a python variable.

With not quotes and no dollar sign:

pipeline= … "_id" : var_id