title: Python TypeError: object is not iterable,
body: <p>I am kinda new to python and trying to create a DTO that minimizes the amount of properties exposed from my api. I use an Azure table storage to get records and then loop over it to create a smaller object omiting properties. Though somewhere in the process I get: &quot;TypeError: 'AbbreviatedPackage' object is not iterable&quot;</p>
  <p>In my main I have the follwing call:</p>
  <pre><code>@app.get(&quot;/list/&quot;)
  def process_results(request: Request, x_api_key: str = Depends(X_API_KEY)):
  
      packageClient = QueryClient(az_connection_string, &quot;appstoredev&quot;)
      results = packageClient.query_packages_storage(&quot;PartitionKey eq 'app'&quot;)
  
      return results
  </code></pre>
  <p>The query_packages_storage()</p>
  <pre><code> def query_packages_storage(self, filter_query):
          from azure.data.tables import TableClient
          table_client = TableClient.from_connection_string(conn_str=self.connection_string, table_name=self.table_name)
          entities = table_client.query_entities(filter_query)
  
          json_entities = []
          for entity in entities:
              print(entity['ImageUrl'])
              filtered_entity = AbbreviatedPackage(
                  entity['ImageUrl'],
                  entity['PackageName'],
                  entity['DisplayName'],
                  entity['Summary']
              )
  
              json_entities.append(filtered_entity)
  
          return json.dumps(json_entities)
  </code></pre>
  <p>AbbreviatedPackage class</p>
  <pre><code>class AbbreviatedPackage():
  
      def __init__(self, image_url, package_name, display_name, summary):
          self.imageUrl = image_url
          self.packageName = package_name
          self.displayName = display_name
          self.summary = summary
  </code></pre>
  <p>When I debug the json_entitiesobject gets filled properly
  <a href="https://i.stack.imgur.com/YTLsD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YTLsD.png" alt="enter image description here" /></a></p>
  <p>Any help would be much sppreciated. Cheers</p>
  <p>** Edit</p>
  <p>I get the errors while being in the loop
  <a href="https://i.stack.imgur.com/YedKt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YedKt.png" alt="enter image description here" /></a></p>
  <pre><code>INFO:     127.0.0.1:60027 - &quot;GET /list/ HTTP/1.1&quot; 500 Internal Server Error
  ERROR:    Exception in ASGI application
  Traceback (most recent call last):
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py&quot;, line 373, in run_asgi
      result = await app(self.scope, self.receive, self.send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py&quot;, line 75, in __call__
      return await self.app(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\fastapi\applications.py&quot;, line 208, in __call__
      await super().__call__(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\applications.py&quot;, line 112, in __call__
      await self.middleware_stack(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\middleware\errors.py&quot;, line 181, in __call__
      raise exc
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\middleware\errors.py&quot;, line 159, in __call__
      await self.app(scope, receive, _send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\middleware\cors.py&quot;, line 84, in __call__
      await self.app(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\exceptions.py&quot;, line 82, in __call__
      raise exc
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\exceptions.py&quot;, line 71, in __call__
      await self.app(scope, receive, sender)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\routing.py&quot;, line 656, in __call__
      await route.handle(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\routing.py&quot;, line 259, in handle
      await self.app(scope, receive, send)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\routing.py&quot;, line 61, in app
      response = await func(request)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\fastapi\routing.py&quot;, line 226, in app
      raw_response = await run_endpoint_function(
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\fastapi\routing.py&quot;, line 161, in run_endpoint_function
      return await run_in_threadpool(dependant.call, **values)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\starlette\concurrency.py&quot;, line 39, in run_in_threadpool
      return await anyio.to_thread.run_sync(func, *args)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\anyio\to_thread.py&quot;, line 28, in run_sync
      return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\anyio\_backends\_asyncio.py&quot;, line 805, in run_sync_in_worker_thread
      return await future
    File &quot;C:\source\IlionxCloud\iliona-store-packages\venv\lib\site-packages\anyio\_backends\_asyncio.py&quot;, line 743, in run
      result = func(*args)
    File &quot;C:/source/IlionxCloud/iliona-store-packages/store-packages/main.py&quot;, line 49, in process_results
      results = packageClient.query_packages_storage(&quot;PartitionKey eq 'app'&quot;)
    File &quot;C:\source\IlionxCloud\iliona-store-packages\store-packages\client\AzureTableEntityQueryClient.py&quot;, line 39, in query_packages_storage
      for entity in entities:
  TypeError: 'AbbreviatedPackage' object is not iterable
  </code></pre>