title: SqlAlchemy: get object instance state
body: <p>This: <a href="http://www.sqlalchemy.org/docs/orm/session.html?highlight=instance%20state#quickie-intro-to-object-states" rel="noreferrer">Intro to object states</a> lists the four permutations of presence-in-DB/presence-in-session:</p>
  
  <pre><code>transient, pending, persistent &amp; detached
  </code></pre>
  
  <p>Is there any way of querying a given object to return which of the four states the object is in?</p>
  
  <p>I tried rooting around in <code>_sa_instance_state</code> but couldn't find anything relevant.</p>
  
  <p>Thanks!</p>