4337 links
  • Arnaud's links
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
page 1 / 1
1 results tagged comprehension x
  • thumbnail
    Show some equivalent list comprehensions in filter examples · Issue #1068 · pallets/jinja · GitHub
    # filter out all elements not with x > 5
    a = [el for el in data if el['x'] > 5]
    
    # get all the 'c' attributes as a list
    b = [el['c'] for el in data]
    
    # get all the 'c' attributes for the elements with x > 5
    c = [el['c'] for el in data if el['x'] > 5]
    
    In Jinja2:
    
    a: {{ data | selectattr('x', 'gt', 5) | list }}
    b: {{ data | map(attribute='c') | list }} 
    c: {{ data | selectattr('x', 'gt', 5) | map(attribute='c') | list }} 
    September 24, 2021 at 11:47:44 AM GMT+2 * - permalink - archive.org - https://github.com/pallets/jinja/issues/1068
    ansible comprehension list python
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation