Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #! /usr/bin/python -u | |
| """ | |
| @author apit - http://fizdoonk.multiply.com/ | |
| @require python-lxml, python-simplejson | |
| """ | |
| import os, sys, re, codecs | |
| import simplejson | |
| import urllib2 |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
| // setup.js | |
| import hook from 'css-modules-require-hook' | |
| import sass from 'node-sass' | |
| hook({ | |
| extensions: [ '.scss' ], | |
| preprocessCss: data => sass.renderSync({ data }).css | |
| }) |