I'll take a hit on this ... It seems like I sometimes see it when I accidentally call a script without specifying a Python interpreter, for example. I say ./foo.py instead of python foo.py or does not have the line #! at the beginning of the script. When I do this, the script will end with a syntax error, and the directory will be filled with files named sys, os, time, et al - these are the modules that I imported in my script. These new files are quite large (7 MB). Running head sys shows the contents of the file are essentially the same as yours. I use Linux (Ubuntu) and not an IDE for my Python development, but only a bash shell.
Here is what I think happens, at least in Linux: if you do man import , you will see
import - saves any visible window on the X server and displays it as an image file. You can capture one window, the entire screen or any rectangular part of the screen.
[...]
The import program is part of the ImageMagick toolkit (1). Use it to capture some or all of the X server screens and save the image to a file.
So, I assume that the shell interprets the first line of Python import statements as /usr/bin/import and uses the "argument" (module name) as the name of the image file to save. Therefore, the PS / ImageMagick material is at the top of the file.
Again, I only see this if I sometimes select and invoke a script without a Python interpreter. Since I donβt know your code or terms of use, I cannot guarantee that this is your exact problem, but I assume that you are doing something similar (perhaps unknowingly). Hope this helps and you get on the right track.
EDIT: Here's an experiment that basically reproduces your problem. The code:
import sys import random import os import time import signal def main(): sys.stdout.write('foo\n') if (__name__ == "__main__"): main()
I call it without Python:
./foo.py ./foo.py: line 8: syntax error near unexpected token `(' ./foo.py: line 8: `def main():'
New files appeared:
$ ls total 25096 -rwxr-xr-x 1 doug doug 146 2013-06-27 10:31 foo.py -rw-r--r-- 1 doug doug 7291759 2013-06-27 10:12 os -rw-r--r-- 1 doug doug 7291763 2013-06-27 10:12 random -rw-r--r-- 1 doug doug 1903418 2013-06-27 10:32 signal -rw-r--r-- 1 doug doug 1903415 2013-06-27 10:32 sys -rw-r--r-- 1 doug doug 7291761 2013-06-27 10:12 time
Look at their contents:
$ head sys %!PS-Adobe-3.0 %%Creator: (ImageMagick) %%Title: (sys) %%CreationDate: (2013-06-27T10:32:20-05:00) %%BoundingBox: 0 0 663 471 %%HiResBoundingBox: 0 0 663 471 %%DocumentData: Clean7Bit %%LanguageLevel: 1 %%Orientation: Portrait %%PageOrder: Ascend
Again, I hope this sheds some light and helps a bit.