<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="moz-cite-prefix">On 2018-02-17 11:23, fhsxfhsx wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:21d694a9.b30.161a493d83e.Coremail.fhsxfhsx@126.com"><span
        style="font-family:monospace">[<br>
          {<br>
            'id': goods.id,<br>
            'name': goods.name,<br>
            'category': gc.name,<br>
            'category_type': gc.type,<br>
          }<br>
          for goods_id in goods_id_list<br>
          for goods is Goods.get_by_id(goods_id)<br>
          for gc is GoodsCategory.get_by_id(goods.category_id)<br>
        ]</span></blockquote>
    <br>
    in the short term, it seems for...in [...] is good enough:<br>
    <br>
    <span style="font-family:monospace">> [<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    {<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'id':
      goods.id,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'name':
      goods.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'category':
      gc.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>       
      'category_type': gc.type,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    }<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    for goods_id in
      goods_id_list<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    for goods in
      [Goods.get_by_id(goods_id)]<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    for gc in
      [GoodsCategory.get_by_id(goods.category_id)]<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>]<br>
    </span><br>
    I personally would like to see with...as... syntax allowed in list
    comprehensions, despite `with` being limited to context managers to
    date.<br>
    <br>
    <span style="font-family:monospace">> [<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    {<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'id':
      goods.id,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'name':
      goods.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'category':
      gc.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>       
      'category_type': gc.type,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    }<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    for goods_id in
      goods_id_list<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    with
      Goods.get_by_id(goods_id) as goods<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    with
      GoodsCategory.get_by_id(goods.category_id) as gc<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>]<br>
    </span><br>
    <span style="font-family:monospace"></span>..,or maybe `let` reads
    easier?<br>
    <br>
    <span style="font-family:monospace">> [<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    {<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'id':
      goods.id,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'name':
      goods.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>        'category':
      gc.name,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>       
      'category_type': gc.type,<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    }<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    for goods_id in
      goods_id_list<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    let goods =
      Goods.get_by_id(goods_id)<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>    let gc =
      GoodsCategory.get_by_id(goods.category_id)<br>
    </span><span style="font-family:monospace"><span
        style="font-family:monospace">> </span>]<br>
      <br>
      <br>
    </span><br>
    <span style="font-family:monospace"></span><br>
    <span style="font-family:monospace"></span>
  </body>
</html>