title: How to find the type of a complicated object
body: <p>Given any python object, is there a way to print out its structure so you can understand how to replace it with an object of equivalent structure?</p>
  
  <p>Context: I've been trying to customise <a href="https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/examples/tutorials/mnist/mnist_deep.py" rel="nofollow noreferrer">this Tensorflow example code</a> so it works with my own data. I seem to be falling down on line 163 at the point where <code>batch[0]</code> and <code>batch[1]</code> are passed to the <code>accuracy.eval()</code> function. I think that <code>batch</code> will be a tuple of two different data types, but I'm really not sure what the data types of these two items are, nor how they relate to basic python types (e.g. I think they should both be numpy <code>ndarray</code> types of different sizes, but does that make them equivalent to lists of lists...?)</p>
  
  <p>I imagine I could sprinkle several <code>print(type(batch[0]))</code> statements to find the answer... across as many edits as my data types are deep. Is there code that will reveal this structure in a single hit, regardless of the data types involved?</p>