Using tuple as parameter to a function

Cecil Westerhof Cecil at decebal.nl
Mon Nov 9 08:40:00 EST 2015


At the moment I have the following calls:
    do_stress_test(  1, 100)
    do_stress_test(  2, 100)
    do_stress_test(  5, 100)
    do_stress_test( 10, 100)
    do_stress_test( 20, 100)
    do_stress_test( 40, 100)

In principal I want to change it to something like:
    do_stress_test('sqlite',    1, 100)
    do_stress_test('postgres',  1, 100)
    do_stress_test('sqlite',    2, 100)
    do_stress_test('postgres',  2, 100)
    do_stress_test('sqlite',    5, 100)
    do_stress_test('postgres',  5, 100)
    do_stress_test('sqlite',   10, 100)
    do_stress_test('postgres', 10, 100)
    do_stress_test('sqlite',   20, 100)
    do_stress_test('postgres', 20, 100)
    do_stress_test('sqlite',   40, 100)
    do_stress_test('postgres', 40, 100)

But that would not be very dry.

I was thinking about something like:
    values = (( 1, 100), ( 2, 100), ( 5, 100),
               10, 100), (20, 100), (40, 100))
    for value in values:
        do_stress_test('sqlite',   ???)
        do_stress_test('postgres', ???)

Is this possible? If so: what do I put at the place of the '???'?

I could change the second and third parameter to a tuple as the second
parameter, but I prefer three parameters if that would be possible.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



More information about the Python-list mailing list