I have a list of directories named dirList. I need to filter and sort before I pickle I think. This is what I've got.

fileHandle = open( 'dirList.txt', 'w' )
fileHandle.write( 'yadda yadda yadda intro' )
cPickle.dump(mu1List, fileHandle)

the mu1List is declared at the beginning and it is a thousand or so part list.

When it prints to the dirList.txt file it has S1(P1 'stringItem', P2 'stringItem1', ...etc)
Is there a way to filter out the P#'s and the items not surrounded by apostrophes? before it gets printed to the .txt? Thanks

The pickle format is encoded. If you want to output the list in plain text, you could try this

from pprint import pprint
pprint(mu1List, fileHandle)