Convert list to sequence of variables

Posted by wtzolt on Stack Overflow See other posts from Stack Overflow or by wtzolt
Published on 2010-04-13T22:19:54Z Indexed on 2010/04/13 22:23 UTC
Read the original article Hit count: 357

Filed under:

I was wondering if this was possible...

I have a sequence of variables that have to be assigned to a do.something (a, b) a and b variables accordingly.

Something like this:

# # Have a list of sequenced variables.
list = 2:90 , 1:140 , 3:-40 , 4:60

# # "Template" on where to assign the variables from the list.    
do.something (a,b)
# # Assign the variables from the list in a sequence with possibility of "in between" functions like print and time.sleep() added.

do.something (2,90)
time.sleep(1)
print "Did something (%d,%d)" % (# # vars from list?)   
do.something (1,140)
time.sleep(1)
print "Did something (%d,%d)" % (# # vars from list?)  
do.something (3,-40)
time.sleep(1)
print "Did something (%d,%d)" % (# # vars from list?)  
do.something (4,60)
time.sleep(1)
print "Did something (%d,%d)" % (# # vars from list?)  

Any ideas?

© Stack Overflow or respective owner

Related posts about python