Not the exact script from the Help, but a similar one:
import arcpy
from arcpy import env
env.workspace = {full path to the database}
arcpy.Compact_management(env.workspace)
I also tried setting a variable equal to the workspace and then running the Compact on the variable rather than directly on the env.workspace with the same results.
I initially ran the above script on the database after adding some non-spatial tables to it and noticed the size increase. I then compacted the database using ArcCatalog, right-click, Administration>Compact database and found that it dropped the size by 1/3. I then reran the same script on the same database and it inflated the size. Compacting through ArcCatalog dropped it back down.
If it helps, I'm running Windows 7 and ArcGIS 10.2.2.3552.