Hi,

I have a for loop something like:

for n in range(no_of_rows):
		#--configuring ODU Op mode
                odu_op_mod=list1[n]
        	odu_op_mode= odu_enum["%s"%odu_op_mod]        
                
                if (odu_op_mod == 'blahblah'):
                        #------------
                
                      

                elif(odu_op_mod == 'aaa'):
                        #--------
		
		elif(odu_op_mode =='xxx'):
                        #-----
		

		elif(odu_op_mod == 'yyy'):
                        #-------------------
                                



		elif(odu_op_mod == 'zzz'):
                        #-------------
                logging.info("*******************************************************************")                
		subprocess.call(['python link_config_idu12.py %s'%addr],shell=True)

I have different lists, list1 #for some mode, list2 #for some mode, i want the first item in list1 to be set followed by first item in list2 and so on.. that is why I am trying a subprocess.call() within the for loop as shown above. But, i see that what i expect is not happening. First all the elements in list1 is getting set, then all the elements in list2 and so on..

where am I going wrong??? please help me out

Recommended Answers

All 5 Replies

anybody pls help me :(

subprocess.call(['python link_config_idu12.py %s'%addr],shell=True)

"addr" is not defined in the code you posted.

But, i see that what i expect is not happening.

What does this mean? To set a list element, you access by the offset, i.e

test_list = [0, 0, 0, 0]
print "Before", test_list
for y in range(5):
    test_list[y] = y
print "After", test_list

Thanks for the reply.
I have defined the addr beforehand, which is not shown above.
I'll try to be a bit more clearer.
i have list1=
list2=
................................
................................
listn=

All the lists are of same length. these list elements are columns of a CSV file. i.e., first element from each list forms the first row of the csv file.

so, i want the first row to be set, then the next row and so on....for the no of rows present in the csv file.

all the lists are of same length. hence,

no_of_rows=len(list1)#---or len(list2),len(listn) for that matter

and before these elements are set, there are a number of checks to be made, which i have written as seperate scripts.

so I want this to happen

for n in range(no_of_rows): #for the no of rows in the csv file
#--------after various checks, set the first element in the first list
#--------do a subprocess call that sets the first element in the second list
#----within the second script do a subprocess call for the third script and so on
#-------when the first element of the nth list is set, 1 row of CSV file is set
#--proceed again as above in the same order

But now, the subprocess call in the first script is called only after all the elements in list1 are set, i.e., my purpose is not getting served. I want the elements to be set 'row wise', but now it is happening 'column wise'.

Does subprocess.call() spawn a process in the back ground??


I have tried my level best to convey what i want to do :( hope I can reach u :( and thanks for ur time for going through this :)

Am I being very vague or silly ? :( can anyone pls help me out?

Hey... I had done an indentation mistake. Such a dumbo i am :) had called subprocess outside the scope of the for loop. Now it is solved.

Anyway thanks for listening :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.