Removing Tabs from Tool Shelf ("T" key) I'm trying to remove unwanted tabs in the left-hand toolshelf, such as "Grease Pencil" and others I never use. I saw an answer here from 2014 that suggested you edit the "space_view3d_toolbar.py" file in C:\Program Files\Blender Foundation\Blender\2.xx\scripts\startup\bl_ui, and comment out the class(es) that pertain to the tab you want to remove using """ at the start and end of the class. 

However, I tried that for the Physics and Relations tabs, and it also removes a bunch of other tabs as well as the top menu. Also, this file doesn't seem to include the "Grease Pencil" or "Layers" tab info. I've done significant C# programming, so I doubt I messed up the commenting... 

I'm wondering if something has changed in recent years. Is there a different file, or maybe I'm missing an easier tweak or add-on somewhere?

Thanks !!
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.