title: How can printing an object result in different output than both str() and repr()?
body: <p>I was testing some code on the interpreter and I noticed some unexpected behavior for the <a href="http://docs.python.org/library/sqlite3.html#sqlite3.Row"><code>sqlite3.Row</code></a> class.</p>
  
  <p>My understanding was that <code>print obj</code> will always get the same result as <code>print str(obj)</code>, and typing <code>obj</code> into the interpreter will get the same result as <code>print repr(obj)</code>, however this is not the case for <code>sqlite3.Row</code>:</p>
  
  <pre><code>&gt;&gt;&gt; print row       # the row object prints like a tuple
  (u'string',)
  &gt;&gt;&gt; print str(row)  # why wouldn't this match the output from above?
  &lt;sqlite3.Row object at 0xa19a450&gt;
  
  &gt;&gt;&gt; row             # usually this would be the repr for an object
  (u'string',)
  &gt;&gt;&gt; print repr(row) # but repr(row) is something different as well!
  &lt;sqlite3.Row object at 0xa19a450&gt;
  </code></pre>
  
  <p>I think <code>sqlite3.Row</code> must be a subclass of <code>tuple</code>, but I still don't understand exactly what is going on behind the scenes that could cause this behavior.  Can anyone explain this?</p>
  
  <p>This was tested on Python 2.5.1, not sure if the behavior is the same for other Python versions.</p>
  
  <p>Not sure whether or not this matters, but the <a href="http://docs.python.org/library/sqlite3.html#sqlite3.Connection.row_factory"><code>row_factory</code></a> attribute for my <code>Connection</code> was set to <code>sqlite3.Row</code>.</p>