Concatenate OR conditional expressions from list to "|"
<p>This probably is a python lang related question, not precisely of boto3 lib:</p>

<p>That query works:</p>

<pre><code>matches = table.query(
    IndexName="status-date-index",
    KeyConditionExpression=Key('status').eq('next'),
    FilterExpression=Attr('teams').contains('a') | Attr('teams').contains('b') | Attr('teams').contains('c')
)
</code></pre>

<p>But I will have a varible list  <code>["a", "b", "c", ...N]</code> and need to convert them to</p>

<pre><code>filter_expression = Attr('teams').contains('a') | Attr('teams').contains('b') | Attr('teams').contains('c') | ...N
</code></pre>

<p>any ideas how to do it in python? or maybe I need to do a better FilterExpression for that case?</p>

<p><a href="http://boto3.readthedocs.io/en/latest/_modules/boto3/dynamodb/conditions.html" rel="nofollow">boto3.dynamodb.conditions.Attr reference.</a></p>

<pre><code>import operator
filter_exp = reduce(operator.or_, (Attr('teams').contains(x) for x in 'abc'))
</code></pre>

python amazon-dynamodb