You can use polygon Selection Contraints rules to automatically expand your selection to the entire shell that surrounds your selected component.
My problem with using this method in a script, and then querying the new selection, is that I prefer to avoid changing the current selection in the middle of a script.
Instead I use the following command, which returns the members of a shell from a single faceID: polySelect.
For example, I've combined a couple of polyPlane meshes into a single object, and I want to list all the faces that belong in the shell that contains pTwinPlane.f, so I script:
string $myMeshObject = "pTwinPlane";
int $faceID = 139;
string $shellFaces = `polySelect -extendToShell $faceID -noSelection -asSelectString $myMeshObject`;
print `ls -flatten $shellFaces`;
This script identifies faces in the shell surrounding f without querying the selected objects, or changing the polygon selection constraint rules. Note: a shell is defined as the shell of poly faces, not the surrounding UV shell.