For most objects, you can get the orientation in world space quite simply:
import maya.cmds as cmds
world_mat = cmds.xform(my_object, q=True, m=True, ws=True)
x_axis = world_mat[0:3]
y_axis = world_mat[4:7]
z_axis = world_mat[8:11]
If you want them in vector form (so you can normalize them or dot them) you can use the maya api to get them as vectors. So for example
import maya.cmds as cmds
import maya.api.OpenMaya as api
my_object = 'pCube1'
world_mat = cmds.xform(my_object, q=True, m=True, ws=True)
x_axis = api.MVector(world_mat[0:3])
y_axis = api.MVector(world_mat[4:7])
z_axis = api.MVector(world_mat[8:11])
# 1 = straight up, 0 = 90 degrees from up, -1 = straight down
y_up = y_axis * api.MVector(0,1,0)
This will include the any modifications that might have been made to the .rotateAxis parameter on the object so it's not guaranteed to line up with the visual tripod if that's been manipulated.
If you don't have reason to expect the .rotateAxis has been set, this the easiest way to do it. A good intermediate step would be just to warn on objects that have a non-zero .rotateAxis so there is no ambiguity in the results, it might be unclear what the correct course of action there is in any case.