Access new objects location after separation of mesh? Hello Blender scripters,

I am a beginner trying hard to work on some scripts. I have been stuck on this problem for some time and any help would be appreciated. 

I have managed to programmatically select vertex groups and separate them into new meshes based on selection. However when I try to access the location of these newly created meshes in object mode they return me the location of the original mesh from which they were separated. 

Is there anyway to calculate the location of these new meshes? Please let me know. Thanks!
After you separate the meshes their origins are still the same as when they were together. This is normal behaviour. After you separate the meshes into its parts you need to set origin to geometry for every newly created mesh.

import bpy

for object in bpy.context.selected_objects:
    bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')  # set origin to geometry


After you do this you will be able to successfully query the new locations.