How to Just Get SQL Statement Error with SQLAlchemy Python Database Wrapper
If you're working with SQLAlchemy, the best database driver for Python, and want to see only SQL syntax errors, you need to use the StatementError exception class. On it, is an attribute `orig`, that contains just the SQL syntax error... and not any data...
Trigrams, Bigrams and Ngrams in Python for Text Analysis
Creating trigrams in Python is very simple
trigrams = lambda a: zip(a, a[1:], a[2:])
trigrams(('a', 'b', 'c', 'd', 'e', 'f'))
# => [('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f')]
You can generalize this a little bit more
How to Decorate Imported Libs in Python for Jinja Template Filters in Flask
To decorate an imported function in Python you would do something like this
# in ./lib.py
# function body
And then in your program you could decorate it like this
from lib import function_name
function_name = decorat...
Get Method Name as String in Python
Here is how to get the string representation of a method in Python
print "Hello World"
# => 'my_method_name'
Short and sweet!
How to Merge a YAML File Into a Single Hash in Ruby
# Nested YAML structure from something-nested.yml
# key: value
# key_two: value_two
# Procedural Approach to building a single Hash from nested YAML data structure.
@yaml = YAML.load_file("something-nested...