def explore_account(c):
 while True:
  print
  folderflags = {}
  data = c.list_folders()
  for (flags, delimiter, name) in data:
   folderflags[name] = flags
  for name in sorted(folderflags.keys()):
   print ('%-30s %s' % (name, ' '.join(folderflags[name])))
  print
  reply = raw_input('Type a folder name, or "q" to quit: ').strip()
  if reply.lower().startswith('q'):
   break
  if (reply in folderflags):
   explore_folder(c, reply)
  else:
   print 'Error: no folder named', repr(reply)

def explore_account ( c ) : while True : print folderflags = { } data = c . list_folders ( ) for ( flags , delimiter , name ) in data : folderflags [ name ] = flags for name in sorted ( folderflags . keys ( ) ) : print ( '%-30s %s' % ( name , ' ' . join ( folderflags [ name ] ) ) ) print reply = raw_input ( 'Type a folder name, or "q" to quit: ' ) . strip ( ) if reply . lower ( ) . startswith ( 'q' ) : break if ( reply in folderflags ) : explore_folder ( c , reply ) else : print 'Error: no folder named' , repr ( reply )
display the folders in this imap account and let the user choose one .