title: Using namedtuple._replace with a variable as a fieldname
body: <p>Can I reference a namedtuple fieldame using a variable?</p>
  <pre><code>from collections import namedtuple
  import random 
  
  Prize = namedtuple(&quot;Prize&quot;, [&quot;left&quot;, &quot;right&quot;]) 
  
  this_prize = Prize(&quot;FirstPrize&quot;, &quot;SecondPrize&quot;)
  
  if random.random() &gt; .5:
      choice = &quot;left&quot;
  else:
      choice = &quot;right&quot;
      
  #retrieve the value of &quot;left&quot; or &quot;right&quot; depending on the choice
  print &quot;You won&quot;, getattr(this_prize,choice)
   
  #replace the value of &quot;left&quot; or &quot;right&quot; depending on the choice
  this_prize._replace(choice  = &quot;Yay&quot;) #this doesn't work
  
  print this_prize
  </code></pre>