how to get the list form dictionary's values

davidbenny2000 at gmail.com davidbenny2000 at gmail.com
Sun Feb 21 08:34:50 EST 2016


  File "mainpy.py", line 81
    for functionlistelement in functionlist0
                                           ^
SyntaxError: invalid syntax


import asyncio

def f000():
 try:
  print "000"
 except:
  print "000 exception"

def f001():
 try:
  print "001"
 except:
  print "001 exception"

def f002():
 try:
  print "002"
 except:
  print "002 exception"

def f003():
 try:
  print "003"
 except:
  print "003 exception"

def f004():
 try:
  print "004"
 except:
  print "004 exception"

machine = {}
mappedfunc = {}
functionlist000 = []
functionlist001 = []
functionlist002 = []
functionlist003 = []
functionlist004 = []

functionlist000.append('002')
functionlist001.append('000')
functionlist002.append('003')
functionlist002.append('004')

functionlist003.append('001')
functionlist004.append('001')

machine000 = {'000': functionlist000}
machine001 = {'001': functionlist001}
machine002 = {'002': functionlist002}
machine003 = {'003': functionlist003}
machine004 = {'004': functionlist004}

machine.update(machine000)
machine.update(machine001)
machine.update(machine002)
machine.update(machine003)
machine.update(machine004)

functionkey000 = {'000': f000 }
functionkey001 = {'001': f001 }
functionkey002 = {'002': f002 }
functionkey002 = {'003': f003 }
functionkey002 = {'004': f004 }

mappedfunc.update(functionkey000)
mappedfunc.update(functionkey001)
mappedfunc.update(functionkey002)
mappedfunc.update(functionkey003)
mappedfunc.update(functionkey004)

def workingthreadpool(currentnumber1, machine1):
 try:
  functionlist0 = machine1.get(currentnumber1)

  loop = asyncio.get_event_loop()
  tesks = []
  
  j = 1
  for functionlistelement in functionlist0
   tesks.append(asyncio.ensure_future(mappedfunc.get(functionlistelement)()))
   if j > 1:
    workingthreadpool(functionlistelement)
   j = j + 1

  loop.run_until_complete(asyncio.wait(tesks))
  loop.close()
 except:
  print "workingthreadpool exception"

currentnumber = "000"
workingthreadpool(currentnumber, machine)


More information about the Python-list mailing list