title: Make tkinter buttons for every item in a list?
body: <p>I would like to make some buttons, with a list of items I get back from a database, that all call a function passing in the list item. Something like this code but that works. The problem with this code is that all of the buttons call the function with <code>'item3'</code>.  </p>
  
  <pre><code>#!/usr/bin/env python
  from Tkinter import *
  root = Tk()
  def func(name):
      print name
  mylist = ['item1','item2','item3']
  for item in mylist:
      button = Button(root,text=item,command=lambda:func(item))
  button.pack()
  
  root.mainloop()
  </code></pre>