Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15021

Re: passing Python data to a javascript function

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.mixmin.net!feed.xsnews.nl!border-3.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'oct': 0.02; 'passes': 0.05; 'stuff.': 0.05; 'subject:Python': 0.06; '(especially': 0.07; 'python': 0.08; 'dancing': 0.09; '--bill': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'it.\xa0': 0.16; 'landing': 0.16; 'subject:function': 0.16; 'wow,': 0.16; 'written': 0.16; 'wrote:': 0.16; 'received:209.85.210.174': 0.18; 'received:mail- iy0-f174.google.com': 0.18; 'seems': 0.20; 'subject:data': 0.21; 'header:In-Reply-To:1': 0.22; 'literal': 0.23; 'pm,': 0.24; 'code': 0.25; 'code.': 0.26; 'thu,': 0.28; 'bit': 0.28; '27,': 0.29; 'message-id:@mail.gmail.com': 0.29; 'script': 0.29; 'thanks': 0.30; 'to:addr:python-list': 0.33; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; "it's": 0.40; 'your': 0.61; 'day,': 0.65; 'unlimited': 0.68; 'client-side': 0.84; 'worrying': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=RPyA+WqO0uvHf+6XHmnJb8x+/T0RIamBc8PRF00QVHI=; b=wEd3Civg2/iT+DHcgEekhilstnr8Gvrwsiat/MWP44+yBPGTVHH9Iay92jBhPqSa95 91GoCaP14WOcJE+p0qJ0aigFvhYblyyIgKzV/cnQKBGaTZGdyXqgObwyAJTt7N372GeS Tqjniy9fhEZ9ze2sDZlUtO3YpJwXicqKZ6bCw=
MIME-Version 1.0
In-Reply-To <CACrcdXuoNuB_c_ewwanOXWXuMT8oEcb4KZiRe7Tgf0Ug81Pq6Q@mail.gmail.com>
References <CACrcdXvi6NDY5CM_AqH0BB6CVx8TRbTBjATu4kbYbcyBJfJNwQ@mail.gmail.com> <CAMuTYXhjuYuouX7+u5h1bE43x9ceWm9aUZ5CoDtu0c2Geuz8ZA@mail.gmail.com> <CACrcdXsXUkLWtkwYADMF-wMjsKjL7VCcSaKW-Y9D83_7Ox5-OQ@mail.gmail.com> <CAMZYqRSNmrazz1VM3VVq0b-KSVKN+JpVFix3fo8-iDaT6wLBvA@mail.gmail.com> <CACrcdXuoNuB_c_ewwanOXWXuMT8oEcb4KZiRe7Tgf0Ug81Pq6Q@mail.gmail.com>
Date Thu, 27 Oct 2011 14:55:28 +1100
Subject Re: passing Python data to a javascript function
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2247.1319687731.27778.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1319687731 news.xs4all.nl 6885 [2001:888:2000:d::a6]:56225
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15021

Show key headers only | View raw


On Thu, Oct 27, 2011 at 2:51 PM, Bill Allen <wallenpb@gmail.com> wrote:
> Chris,
>
> Wow, that seems so simple now that I see it.  I was dancing around that all
> day, but just not landing on it.   Thanks so very much for the assist.
>
> --Bill
>
> Final code that works perfectly, passes the value from the Python script to
> the javascript correctly:
>
> <body onload="showPID("""+pid_data+""")">

Congratulations! You've just written code that writes code. It takes a
bit to get your head around it (especially when you start worrying
about literal strings that might contain quotes, for instance), but
it's really cool and seriously powerful stuff. Your server-side Python
code can generate client-side Javascript code any way it likes...
unlimited possibilities.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: passing Python data to a javascript function Chris Angelico <rosuav@gmail.com> - 2011-10-27 14:55 +1100

csiph-web