Blender as python module, 'Context' object has no attribute 'object' I understand that running blender without a GUI does not provide bpy.context for the 3d View. Can anyone help me with a work around. This results in a 'Context' object has no attribute 'object' error.  

for scene in bpy.data.scenes:
    for object in scene.objects:
        if bpy.context.mode == 'OBJECT':
            if object.name != 'Lamp':
                if object.name != 'Camera':
                    print("deleting " + object.name)
                    bpy.ops.object.delete(use_global=False)
                    bpy.ops.mesh.primitive_cone_add({'scene': scene, 'active_object': object})
                    print(bpy.context.object)
Variables are not always available in the context, typically you can access them directly, in the case of the active object you can access it from 
scene.objects.active (most collections that have an active member work this way).