Matplotlib includes a function to determine if a set of points is within a polygon, called points_inside_poly. For an example see http://matplotlib.sourceforge.net/faq/howto_faq.html#test-whether-a-point-is-inside-a-polygon
That is about as simple as it gets from a user's perspective!
Since you ask about tricks in plot functions, no there aren't any. Rendering functions don't explicitly determine if a contour polygon is an inner or outer boundary. Usually a sweep algorithm is performed across all points to construct the triangulation of the polygons as it progresses. You could extract the inner/outer-ness of each boundary from such an algorithm but it would be overkill for what you want to do.