title: Scanning dynamodb with optional parameters
body: <p>Im new with dynamodb and Im trying to make a function to scan a table and have an optional parameter but Im not quite sure how to implement it. This is the code I have so far:</p>
  <pre><code>def scan_table(table, store=None, dynamodb=None):
      if not dynamodb:
          dynamodb = boto3.resource('dynamodb')
  
      response = table.scan()
      data = response['Items']
  
      while 'LastEvaluatedKey' in response:
          response = table.scan(
              FilterExpression=Key('store').eq(store),
              ExclusiveStartKey=response['LastEvaluatedKey'],
              ProjectionExpression=&quot;UID, #name, description&quot;,
              ExpressionAttributeNames={'#name': 'name'}
          )
          data.extend(response['Items'])
      return data
  </code></pre>
  <p>So ideally what I'd want to happen is if I pass in a store for example <code>&quot;walmart&quot;</code> I only get products from walmart. However If I dont pass anything I would get ALL products in the entire table. How can I do that in an elegant way.</p>