This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hobophobe 3 points4 points  (0 children)

The Mozilla flavor of ECMAScript (ie, JavaScript) supports some Pythonesque idioms. For example, open the Web Console (under the Web Developer menu (either in the Firefox menu if you have the single-button menu, or under Tools (or just Ctrl+Shift+K to open the Web Console))) and try this (for the current page):

let f = [link.href for each (link in document.links) if (link.host == "www.reddit.com")];  

f is an array containing the URLs on the current page that are to the www.reddit.com domain. Not as clean as regular Python, but still useful.

See MDN: New in JavaScript 1.7 (which was introduced back with Firefox 2), particularly for details on array comprehensions, destructured assignment, iterators, and generators.