title: What is the Python way of chaining maps and filters?
body: <p>I'm currently learning Python (coming from other languages like JavaScript and Ruby). I am very used to chaining a bunch of transformations / filters, but I'm pretty sure that's not the right way to do it in Python: <code>filter</code> takes a lambda before the enumerable, so writing a long / multi-line function looks really weird and chaining them means putting them in reverse order which isn't readable.</p>
  
  <p>What would be the "Python way" of writing the maps and filters in this JavaScript function?</p>
  
  <pre><code>let is_in_stock = function() /* ... */
  let as_item = function() /* ... */
  
  let low_weight_items = shop.inventory
      .map(as_item)
      .filter(is_in_stock)
      .filter(item =&gt; item.weight &lt; 1000)
      .map(item =&gt; {
          if (item.type == "cake") {
              let catalog_item = retrieve_catalog_item(item.id);
  
              return {
                  id: item.id,
                  weight: item.weight,
                  barcode: catalog_item.barcode
              };
          } else {
              return default_transformer(item);
          }
      });
  </code></pre>
  
  <p>I understand that I might use a list comprehension for the first map and the next two filters, but I am not sure how to do the last map and how to put everything together.</p>
  
  <p>Thank you!</p>