Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/usr/bin/env python | |
| import pudb | |
| import random | |
| # infinite prime number generator | |
| def gen_prime(): | |
| tbl = dict() | |
| i = 2 | |
| while True: |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/usr/bin/env python2 | |
| import re | |
| _, lines, cases = map(int,raw_input().split()) | |
| words = [] | |
| for _ in xrange(lines): | |
| words.append(raw_input()) | |
| for c in xrange(cases): |
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
| import XMonad | |
| main = xmonad defaultConfig | |
| { modMask = mod4Mask -- Use Super instead of Alt | |
| , terminal = "urxvt" | |
| -- more changes | |
| } |
| # -*- mode: python -*- | |
| # -*- coding: utf-8 -*- | |
| # edit this file to match your settings and copy it to ~/.jhbuildrc | |
| # if you have a GNOME git account, uncomment this line | |
| # repos['git.gnome.org'] = 'ssh://[email protected]/git/' | |
| # what module set should be used. The default can be found in | |
| # jhbuild/defaults.jhbuildrc, but can be any file in the modulesets directory |
| #!/usr/bin/env bash | |
| # Written by William Ting for the following blog post: | |
| # http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/ | |
| rcfile="${HOME}/.bashrc" | |
| version="2.7.3" | |
| setuptools_version="2.7" | |
| tmp_dir="${HOME}/tmp-${RANDOM}" | |
| if [[ ${#} == 0 ]]; then |
| #!/usr/bin/env python2 | |
| # This program shows off a python decorator( | |
| # which implements tail call optimization. It | |
| # does this by throwing an exception if it is | |
| # it's own grandparent, and catching such | |
| # exceptions to recall the stack. | |
| import sys | |
| class TailRecurseException: |
| *.tar.xz | |
| pkg/ | |
| src/ |
| require 'digest/md5' | |
| def gfm(text) | |
| # Extract pre blocks | |
| extractions = {} | |
| text.gsub!(%r{<pre>.*?</pre>}m) do |match| | |
| md5 = Digest::MD5.hexdigest(match) | |
| extractions[md5] = match | |
| "{gfm-extraction-#{md5}}" | |
| end |