As a general solution for passing data from Python to Javascript, consider serializing it with the json library (part of the standard library in Python 2.6+).
>>> sample = "hello'world"
>>> import json
>>> print json.dumps(sample)
"hello\'world"
As a general solution for passing data from Python to Javascript, consider serializing it with the json library (part of the standard library in Python 2.6+).
>>> sample = "hello'world"
>>> import json
>>> print json.dumps(sample)
"hello\'world"