On 13 July 2013 20:03, Steven D'Aprano <st...@pearwood.info> wrote: > > I don't understand that last sentence.
Ah, I can be marvelously unclear. I keep forgetting telepathy only works on my home planet ;') I wiped everything out to start fresh with Py27, so this is just a very simple example of what worked in sending a few million test integers to my numbers-to-name program, which normally took typed input. The real test program used randoms to go up to the decillions and a straight count to go into the quadrillions, for about 40 tests (before my CPU overheated, this being Arizona ;') No doubt there is a standard way to do this, but I wanted to test the numbers program quickly, without mooching all over the net, so I threw something like this together: # The module I import, inputter.py: #Using Python 2.7 on Win 7 def inp(): x = raw_input('type a number: ') return x def intest(): if int(inp()) < 10: print('smallnum') else: print('bignum') def main(): intest() if __name__ == '__main__': main() # The Test Program, test.py that imports the module above: # Using Python 2.7 on Win 7 import inputter x = (x for x in xrange(8,13)) # much bigger, and sometimes random, in the real test program def testfunc(): # This is where my typed input is replaced return next(x) inputter.inp = testfunc for cnt in range(0,5): inputter.intest() '''result: smallnum smallnum bignum bignum bignum '''
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor