title: How to get min and max value of member in list in one pass?
body: <p>I can use <code>functools.reduce</code> or <code>min</code> / <code>max</code> to get min and max of members in a list. But to get both in one pass I need to write a loop:</p>
  <pre><code>from functools import reduce
  
  class foo:
      def __init__(self,value): self.value = value
      
  x = []
  x.append(foo(1))
  x.append(foo(2))
  x.append(foo(3))
  
  min_value = reduce(lambda a,b: a if a.value &lt; b.value else b,x).value
  max_value = reduce(lambda a,b: a if a.value &gt; b.value else b,x).value
  
  print(min_value)
  print(max_value)
  
  min_value2 = min(x,key=lambda a: a.value).value
  max_value2 = max(x,key=lambda a: a.value).value
  
  print(min_value2)
  print(max_value2)
  
  min_value3 = x[0].value
  max_value3 = x[0].value
  for f in x:
      if f.value &lt; min_value3: min_value3 = f.value
      if f.value &gt; max_value3: max_value3 = f.value
      
  print(min_value3)
  print(max_value3)
  </code></pre>
  <p>Is it possible to get <code>min</code> and <code>max</code> in one pass without writing a plain loop?</p>