Actually, my workflow is: (1) develop the script within Eclipse (with sys.argv), (2) debug it within Eclipse, (3) run it as a tool in ArcGIS or as a script in Windows command line.
As you see, my problem is to determine **at runtime** if the script is called as a tool from within ArcGIS or directly from PythonWin (or others). This would allow me to change the output formating/debug information displayed according to the context (for instance avoiding the use of gp.addmessage when run in command line mode). Your solution would only work to evaluate for which primary purpose the code has been developed (tool or script), right?
In other suggestion?
Benoit