Just to add up to the great answer above, one must be in OBJECT
mode in order to delete objects. In order to do so in Python use the following code:
bpy.ops.object.mode_set(mode='OBJECT')
It also makemakes sense to return to previous mode, after the operation:
oldMode = bpy.context.mode
bpy.ops.object.mode_set(mode='OBJECT')
...Select your object here
bpy.ops.object.delete()
bpy.ops.object.mode_set(mode=oldMode)