Double quotes.
Brackets.
w_pattern, not pattern_w.
Add rather than join.
OrderedDict is better than list and dict.