On Mar 12, 12:52 pm, Chris <[EMAIL PROTECTED]> wrote: > On Mar 12, 12:32 pm, "k.i.n.g." <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I would like create files of different size, taking size as user > > input. I need to check the data transfer rates from one network to > > another . In order to do this I will have to create files of diff size > > and work out. I am new to Python > > > Thanks in advance. > > > KK > > Welcome to Python. > > If you just want to create files with random junk from the user input > then maybe something along these lines would help: > > import sys, random > > def random_junk(number_of_characters): > tmp = [] > while number_of_characters: > tmp.append(random.randint(0, 127)) > number_of_characters -= 1 > return ''.join(map(str,tmp)) > > if len(sys.argv) < 2: > sys.exit('Usage:python %s <space seperated > filesizes>'%sys.argv[0]) > > for each_argv in sys.argv[1:]: > output_file = open(each_argv,'wb').write(random_junk(each_argv))
Sorry, meant def random_junk(number_of_characters): tmp = [] while number_of_characters: tmp.append(chr(random.randint(0, 127))) number_of_characters -= 1 return ''.join(tmp) -- http://mail.python.org/mailman/listinfo/python-list