title: disabling XML output for the type() function in Python
body: <p>I'm working with an external compiled API, that does some XML manipulation prior to screen rendering. I am passing data to and from the API, and I want it to break cleanly so I can see where it is broken. This means I need to be able to send it text, rather Pythons internal formatting for types. </p>
  
  <p>So I need to debug what types I'm sending and recieving. type() hands back xml?, and isinstance() would require testing every possible type. </p>
  
  <p>So is there an alternative that will give me the stringified type that is suitable for inline evaluation? </p>
  
  <p>Example:</p>
  
  <pre><code>mystring = str("") 
  print (type(mystr))
  
  returns &lt;class "str"&gt;
  </code></pre>
  
  <p>If I am passing angle brackets into a binary API, I have no idea what it is doing with the data, or whether it will render in the UI at all. It does its own string parsing based on code I don't have, or even want to know. </p>
  
  <p>The only part I care about is: "str". </p>
  
  <p>So I have: </p>
  
  <pre><code>mystr = str("")
  blackbox.String(mystr)
  </code></pre>
  
  <p>Where the contents and even type of mystr are unknown. (the string value is also handed to me by a blackbox) The API is rendering nothing. Though I don't know whether the fact that it is rendering nothing is because of bad string formatting, or a bad type, or because there is a string, but it is empty. I know it is SUPPOSED to be a text string with length. But I don't know if it is. If I use isinstance I have to know what I'm testing for. Which tells me nothing if I'm getting something weird. If I use type() I am sending something weird to the rending engine. So I am screwed both ways. </p>
  
  <p>What I need is: </p>
  
  <pre><code>blackbox.String(type(mystr))
  </code></pre>
  
  <p>where the result of type is a plain ascii type name without punctuation, so that I can reasonably assess that the black box is giving and getting a plain, untainted text string. </p>