Python: add object, then change properties
When using add primitive operators, the object that is created is marked as the active object. You can access the active object using obj = bpy.context.active_object.