(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import bs4 | |
def xpath_soup(element): | |
# type: (typing.Union[bs4.element.Tag, bs4.element.NavigableString]) -> str | |
""" | |
Generate xpath from BeautifulSoup4 element. |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
This is an example of a collapsible drag and drop tree implementing slightly modified code from https://gist.github.com/robschmuecker/7880033
This is posted in order to demonstrate a viable answer for a Stack Overflow question http://stackoverflow.com/questions/20539922/has-anyone-produced-a-virtualised-javascript-tree-for-thousands-of-nodes
The only difference between this gist and the one referenced above is that the JSON file has changed. Each node contains 15 children and the depth is 4. Hence over 50,000 nodes.
The performance is fine if not too many of the nodes are present at once in the DOM. The JSON was contructed at http://www.json-generator.com/ with the following markup
class Hangman(): | |
def __init__(self): | |
print "Welcome to 'Hangman', are you ready to die?" | |
print "(1)Yes, for I am already dead.\n(2)No, get me outta here!" | |
user_choice_1 = raw_input("->") | |
if user_choice_1 == '1': | |
print "Loading nooses, murderers, rapists, thiefs, lunatics..." | |
self.start_game() | |
elif user_choice_1 == '2': |
Using Requests and Beautiful Soup, with the most recent Beautiful Soup 4 docs.
Install our tools (preferably in a new virtualenv):
pip install beautifulsoup4
// It is important to declare your variables. | |
(function() { | |
var foo = 'Hello, world!'; | |
print(foo); //=> Hello, world! | |
})(); | |
// Because if you don't, the become global variables. | |
(function() { |