Reputation: 31
Input file in two different cases:
case1:
inputfile:
one-device:yes
number of device:01-05
first-device:
second-device:
Case2:
one-device:no
number of device:01-05
first-device:01-03
second-device:04-05
Now in case 1 i have only one start and end value that is 01 and 05
Functions I have is:
def func1(self, start, end):
for i, x in enumerate (range(start, end)):
do something
def func10 (self, start, end):
do something
case 2: i have 2 different start and end value that is for first device 01-03 and 04-05.
In case 1 my program execution flow.
# if one-device input is yes
func1(arg1, agr2)
func2(arg1, agr2)
func3(arg1, agr2)
func4(arg1, agr2)
func5(arg1, agr2)
func6(arg1, agr2)
func7(arg1, agr2)
func8(arg1)
func9(arg1, agr2,arg3)
func10(agr1,arg2)
func11(arg1, agr2)
func12(arg1, agr2)
func13(arg1)
#if one-device input is no.
#In case2. i need to call two times functions func1 and func10.
my program execution flow like for case 2 is:
# run two times with two diffewnt start and end values as per input in case 2
func1(arg1, agr2)
func1(arg1, agr2)
#flow continues as usal
func2(arg1, agr2)
func3(arg1, agr2)
func4(arg1, agr2)
func5(arg1, agr2)
func6(arg1, agr2)
func7(arg1, agr2)
func8(arg1)
func9(arg1, agr2,arg3)
# run two times with two diffewnt start and end values as per input in case 2
func10(agr1,arg2)
func10(agr1,arg2)
#flow continues as usal
func11(arg1, agr2)
func12(arg1, agr2)
func13(arg1)
Now question is i want to use if else statement to check one-device is yes or no.
if one-device is yes write case 1 flow
if one-device is no write case 1 flow
if no write same flow with using for loop for func1 and func10 to run two times.
If i use this method my code be be lot of duplicate .
I need help here
Upvotes: 0
Views: 2827
Reputation: 697
I'm not sure if I understood the question. But from what I understood, I think you want the function to be able to accept variable number of arguments:
def f1(arg1, *args):
print "first arg: ", arg1
for arg in args:
print "next arg:", arg
f1(1, "string", 3,4)
Please let me know if this is what you were looking for?
Upvotes: 2