Q:

How to feed lists from python into javascript?

I'm pretty new to Javascript. I was wondering, how does importing lists generated by Python work? Below is a rough version of what I'm thinking, I'm trying to import 3 lists into an HTML file using javascript (apologies in advance if any of the syntax is off.):
function createMarkers(){
  //import article_list generated by headline.py
  //import urls from generated by headline.py
  //import coordinates generated by headline.py
  for (i = 0; i < 25;) {

  article_name = article_list[i]
  url = urls[i]
  coordinate = coordinates[i]

  var marker[i] = WE.marker([coordinate]).addTo(earth);
  marker.bindPopup("<b>article_name</b><br><a href="url">url</a>, {maxWidth: 520, closeButton: true});
  }

}

Do I need to implement some sort of web framework to execute the python code and feed it into this javascript code? How would I go about doing this?

A:

Have you looked into templating languages? I have solved a similar problem using Jinja2.
Here are some Docs.
Here is a Quickstart tutorial.
Below is an example.
The variable markers is injected into the HTML, using Jinja2
Python code:
import webapp2 # Le framework
import json    # This is used to return the dictionary in a native (to JS) way
import jinja2  # The glue

# This example uses webapp2, but could be easily adapted to other frameworks.
jinja_environment = jinja2.Environment(
    # sets the folder "templates" as root folder for html (can be tweaked to match you layout):
    loader=jinja2.FileSystemLoader('templates')) 

class Marker():
"""
creates marker objects that can then be rendered on the map.
"""

def __init__(self, latlng, title):
    # below we split the comma-separated latlng into two values and store in an array.
    coords = str(latlng).split(',')
    self.lat = coords[0]
    self.lng = coords[1]
    self.title = title

class MainHandler(webapp2.RequestHandler):
    def get(self):
        # assembling the coordinates and descriptions into an array of Marker objects
        markers = []
        for marker in list_of_markers:
            markers.append(Marker(latlng="coordinates go here in format 'latitude, longitude'",
                                  title="Marker title goes here")

        for marker in markers:
           t_dict = {}
           t_dict['m_title'] = marker.title
           t_dict['m_lat'] = marker.lat
           t_dict['m_lng'] = marker.lng
           temp.append(t_dict)
        json_markers = json.dumps(temp)

        template_values = {'markers' :json_markers}

        template = jinja_environment.get_template('index.html')
            self.response.out.write(template.render(template_values))

# Initializing the webapp:
application = webapp2.WSGIApplication([('/', MainHandler)], debug=False)

Javascript code:
// To be added to the initialize() function of the maps JS:
data = {{ markers }} 

// Iterating over list of points to create markers:
data.forEach(function(p) {
     var point = new google.maps.LatLng(p.m_lat, p.m_lng);
     var marker = new google.maps.Marker({position: point,
         map: map,
         title: p.m_title,
         //animation: google.maps.Animation.DROP,
     });
 });

