I'm not extremely familiar with gnuplot-py -- but if it writes the commands to the terminal as it executes them, you can just use shell redirection:
python myPythonScriptWithGnuplot.py > commandfile.gp #redirect stdout
python myPythonScriptWithGnuplot.py 2> commandfile.gp #redirect stderr
Of course, this won't help if you're writing other things to the terminal from python ...
But note that gnuplot-py sends the data to gnuplot via a temporary FIFO (I think anyway). So, if you're plotting data (e.g. lists, numpy arrays, etc ... not functions like "sin(x)"), when you try to plot the data, the FIFO will have been purged from your system and your plot command will fail complaining it can't find the datafile.
EDIT
After a (quick) look at the source, it appears you have a few options. Your first option: pass debug=1 to the constructor (You already might be doing this). This will cause the commands to be written to standard-error. with a little (or a lot) of shell magic, you can separate out the different output streams. Here's a recipe to put stderr from a command into a file while still leaving the output on your terminal that works in bash (I'm using bash 4.1.5 -- but I'm pretty sure this has been around for a while):
((command 3>&1 1>&2 2>&3 ) | tee command_stderr.log ) 3>&1 1>&2 2>&3
#swap stderr/out
#tee puts data in output file and to terminal
#swap stderr/stdout again.
(I'd love to see a cleaner way to do this output stream swapping if anyone knows it...)
Alternatively, you can pass a filename to the Gnuplot constructor. This will write the commands to that file. As far as I can tell, there's no method to allow you to write the commmands to the file and to the gnuplot pipe. However, you can always start up multiple Gnuplot instances and write the commands to a file via the main instance and then whenever you write a plot command, tell the second instance to load "filename". Of course, if you use this method, you should probably specify that the data should be inlined.
A third option is to abandon gnuplot-py in favor of pyGnuplot since I'm still actively developing that one -- Then if something doesn't work, or you'd like to have a feature added, you can just let me know ;)