Python script that generates blob files

Peter L Hansen peter at
Fri Oct 8 16:23:54 CEST 2004

Sean Carey wrote:
> I am wondering if anyone knows of a python script or any other script
> that will generate random files with random sizes that I can specify.

Presumably using the random module would help?

length = random.randint(0, 1000)
filename = 'test'

f = open(filename, 'wb')
i = 0
while i < length:
     f.write(chr(random.randint(0, 255)))

Slight variations could simplify this...  use getopt or optparse
to retrieve command line arguments if you want to specify different
filenames or length ranges etc.


More information about the Python-list mailing list