title: Find the type of an attribute in a class
body: <p>I want determine the type of an attribute in a class.  I am using <code>setattr</code> to set the value, and I would like to check the type that is expected, so that I can properly convert a string value before calling <code>setattr</code>.</p>
  
  <p>How do you do this in python?</p>
  
  <p>EDIT 1-
  Some additional information based on the answers so far:</p>
  
  <p>I only know the name of the property that I want the type for, here is some code:</p>
  
  <pre><code>def populate_object_properties(values_as_strings, 
                                 object_to_populate, 
                                 properties_to_populate):
      for k in properties_to_populate:        
          value = values_as_strings.get(k)
          if value:
              setattr(object_to_populate, k, value)
          else:
              setattr(object_to_populate, k, None)
  </code></pre>
  
  <p>I want to be able test that <code>value</code> is the right type before I call <code>setattr</code>.</p>
  
  <p>Edit 2- The reason why I need to validate the type, is that I'm using Google AppEngine's db.Model as the base type for the <code>object_to_populate</code>, and it doesn't like when a put a string into an <code>int</code> type.  I was trying to keep the question as simple as possible, but maybe that piece of information makes a difference in how someone would answer.(?)</p>