[Edu-sig] Python + JS == more than their sum()

Wes Turner wes.turner at gmail.com
Tue Nov 22 10:15:04 EST 2016


Some tips and resources for learning about Python and JS:

mpld3 brings together Python and d3 Javascript data visualization library:
Docs: http://mpld3.github.io
Src: https://github.com/mpld3/mpld3


I haven't reviewed these sources for Code Injection bugs that do occur when
e.g. generating JS with another language. ("XSS": "Cross-site scripting").
- http://cwe.mitre.org/top25/#CWE-79
 *Improper Neutralization of Input During Web Page Generation ('Cross-site
Scripting')*

About JSON:

- JSON should be parsed.
  - http://seriot.ch/parsing_json.php
- JSON should not be eval()'d; because it could contain code.
- While it's possible to template JSON into an HTML page, we usually like
to retrieve the data separately from the code (because then we can cache
the code and data separately); so REST or RPC API.
  -
https://github.com/mgonto/restangular/blob/master/README.md#differences-with-resource
 -
https://www.quora.com/Is-it-possible-to-consume-a-RESTful-API-with-React-js-alone-i-e-without-any-server-side-language-provided-the-API


- JSONLD is a spec for Linked Data in JSON. There's a @context which
defines URI namespaces for schema. JSON object {attributes:}, then, map to
URIs. http://json-ld.org/playground/
- RDFJS apps can work with JSONLD.
- There are other data interchange specs with JS support (Protocol Buffers,
Thrift, Avro, Arrow, ).


PyJS contains a Python to JS compiler
Docs: http://pyjs.org
Src: https://github.com/pyjs/pyjs


Brython includes a Python interpreter written in JS; for use of Python as a
HTML5 script language:
Docs: https://brython.info
Src: https://github.com/brython-dev/brython

- Like Javascript, Brython has a DOM (Document Object Model) API:
https://brython.info/static_doc/en/dom_api.html


Folium integrates Python data and a JS data visualization library called
leaflet.js:
Src: https://github.com/python-visualization/folium

Btw, (e.g. for a flipped classroom) these are great:
- https://www.codecademy.com/courses/learn-git
- https://www.codecademy.com/courses/learn-javascript (... jQuery, Angular,
React)
- https://www.codecademy.com/tracks/python (...
-  https://www.codecademy.com/apis (APIs! have request limits)


On Monday, November 21, 2016, kirby urner <kirby.urner at gmail.com> wrote:

>
> I'm continuing to advance the notion, in
> Medium comments and elsewhere, that
> learning one computer language at a
> time may be less efficient than tackling
> two or more, but with a "main one" front
> burner. [1]
>
> I credit the LEX Institute for this idea.[2]
>
> The theory being: contrasts and comparisons
> help concepts stick, whereas just one example
> (of a language, human or computer) provides
> less traction, a slipperier slope.
>
> Like learning the J language (jsoftware.com)
> even a little helps one realize how different
> languages can be, bringing Python into sharper
> relief against a background.
>
> But J (of APL heritage) might be too exotic
> as a #2, why not do JavaScript?  Python + JS
> could be as common as HTML + CSS.
>
> That's a little self serving as a common bootcamp
> design if JS front end, Python back end. Our
> PDX Code Guild in Portland takes that tack.
>
> The curriculum, then, would continually bring
> them together to discuss their similarities and
> differences.  Either one could be foreground
> first, with the other as background, but we'd
> do a lot of jumping back and forth (and not
> just with JSON :-D).
>
> A breakthrough realization I had earlier today
> was that Jupyter Notebooks already gives me
> a JavaScript interpreter, even when my main
> kernel is Python 3.
>
> %%javascript at the top of any cell creates a
> node-like experience, and I'm able to write
> ES6 (JavaScript) with classes, arrow functions
> and everything.  It feels a lot like using
> node --harmony testfile.js on cloud9 (another
> learning platform I visit).
>
> Here's an example, of a Jupyter Notebook
> running through nbviewer, with both Python
> and JS code cells.  The point is to show off
> the similarities.
>
> https://goo.gl/nj9RPO
>
> Kirby
>
> Useful tools:
> http://codepen.io/
> http://jsbin.com/
>
> [1] https://goo.gl/U4Yx6l (comment on one
> of Quincy Larson's, about which language
> to learn first)
>
> [2] 'Who Is Fourier?' (one of its pubs) appears
> way back in edu-sig.  Jason Cunliff and I
> met and talked about it in New York that
> time.
>
> Here's one of Jason's from 2002:
>
> https://mail.python.org/pipermail/edu-sig/2002-September/002255.html
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20161122/a160b4b9/attachment.html>


More information about the Edu-sig mailing list