title: remove last comma from dictionary/list
body: <p>I am trying to python to generate a script that generates unload command in redshift. I not an expert Python programmer. I need to where I can generate all columns for the unload list. If the column is of specific name, I need to replace with a function. The challenge I am facing is it appending "," to last item in the dictionary. Is there a way I can avoid the last comma? Any help would be appreciated.</p>
  
  <pre><code>import psycopg2 from psycopg2.extras 
  import RealDictCursor 
  
  try: 
      conn = psycopg2.connect("dbname='test' port='5439' user='scott' host='something.redshift.amazonaws.com' password='tiger'"); 
  except: 
      print "Unable to connect to the database"
  
  conn.cursor_factory = RealDictCursor 
  cur = conn.cursor()
  conn.set_isolation_level( psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT )
  
  try: 
      cur.execute("SELECT column from pg_table_def where schema_name='myschema' and table_name ='tab1' " ); 
  except: 
      print "Unable to execute select statement from the database!"
  
  result = cur.fetchall()   
  print "unload mychema.tab1 (select " 
  
  for row in result: 
      for key,value in row.items(): 
          print "%s,"%(value)
  
  print ") AWS Credentials here on..."
  
  conn.close()
  </code></pre>