You can either get the transform's worldMatrix (wm) attribute using getAttr, or use the "xform -query -worldSpace -matrix" command.
In either case you get an array of 16 floats, which is in fact the flattened (i.e. in array form, not matrix) world space transformation matrix. if this matrix is
{M00, M021, M02, M03, M04, M05, M06, M07, M08, M09, M10, M11, M12, M13, M14, M15},
then it looks like this in matrix form:
| M00 M01 M02 M03 |
| M04 M05 M06 M07 |
| M08 M09 M10 M11 |
| M12 M13 M14 M15 |
Ok, So how does this answer your question?
Well, the nice thing about the world transformation matrix is that the elements translate very easily into the direction, scale, shear and translation of the local axes in world space:
Translation: {M12, M13, M14}
Direction of x-axis: {M00, M01, M02}
Direction of y-axis: {M04, M05, M06}
Direction of z-axis: {M08, M09, M10}
In short, the axes directions are stored in the upper left 3x3 submatrix, and the translation is stored in the left subvector of the bottom row.
Afaik, the last column of the matrix ({M03, M07, M11, M15}) is always {0, 0, 0, 1}, because the matrix is affine (don't ask me what that means though).
So, when you get the flattened matrix using getAttr or xform, you can determine the axes in vector form like this:
float $flatMatrix [16] = xform -q -ws -m $the\_object
;
vector $wTranslation = <>;
vector $wLocalXAxis = <>;
vector $wLocalYAxis = <>;
vector $wLocalZAxis = <>;
note: getting the axes this way doesn't guarantee that the axes are unitized (i.e. their magnitude is 1), or perpendicular. If the object is scaled, this will reflect in the values (the axes' magnitude will not be 1). Same thing with shear (the axes will not be perpendicular to eachother).