Removing Tabs from Tool Shelf ("T" key)
Unregister the classes.

Rather than mess with the UI code, you can unregister the classes.  When a class is registered it is added to bpy.types  Using autocomplete in python console, dir(bpy.types) or looking at bl_ui.space_view3d_toolbar we can find the classes we wish to unregister. 

Let's take the grease pencil tool bar panels as an example. The naming convention shows the panels we wish to remove start with VIEW3D_PT_tools_grease_pencil  Similarly for animation.

Test script to remove grease pencil and animation 3d view toolbar.

import bpy
from bpy.utils import unregister_class

gpclasses = [c for c in dir(bpy.types)
        if c.startswith("VIEW3D_PT_tools_grease_pencil")
        or c.startswith("VIEW3D_PT_tools_animation")]

for c in gpclasses:
    cls = getattr(bpy.types, c)
    unregister_class(cls)


Change above script to suit.

Hit F8 to reinstate the panels.