How do you delete an object programmatically?

In a script I’m writing, I need to delete a couple of objects, just as if the user had pressed X. I don’t see any function for this in the documentation, though. I assume this is possible — can some kind person fill me in?

Well… you can’t technically “delete” it, but you can “unlink” it. This will cause it not to be included the next time the blend is saved (a reload after this will not include the object).

Basically as I understand it to fully prepare an object for this is 1) to unlink it from all scenes and 2) make sure it’s “fakeUser” attribute is set to false.