Contextual Logger for Python
>>> logging.basicConfig(level=logging.INFO)
>>> logger = logging.getLogger()
>>> cxtlgr = cxtlog.wrap(logger)
\hat{r}_{u,i} = \bar{r_u} + \frac{1}{|I_u|} \sum\limits_{i' \in I_u} \operatorname{sim}(i, i') (r_{u, i'} - \bar{r_u}) |
MORSE_SIGNS = { | |
"a": ".-", "b": "-...", "c": "-.-.", "d": "-..", "e": ".", "f": "..-.", | |
"g": "--.", "h": "....", "i": "..", "j": ".---", "k": "-.-", "l": ".-..", | |
"m": "--", "n": "-.", "o": "---", "p": ".--.", "q": "--.-", "r": ".-.", | |
"s": "...", "t": "-", "u": "..-", "v": "...-", "w": ".--", "x": "-..-", | |
"y": "-.--", "z": "--..", | |
} | |
def decrypt_morse(morse): |
--- | |
pyenv_root: /opt/pyenv | |
pyenv_rcfiles: [] | |
pyenv_versions: [] | |
pyenv_global_version: system | |
pyenv_build_requirements: | |
# https://github.com/pyenv/pyenv/wiki/Common-build-problems | |
- zlib-devel | |
- bzip2 | |
- bzip2-devel |
--- | |
python_version: 3.6.2 |
import re | |
from collections import namedtuple | |
import MeCab | |
Node = namedtuple('Node', [ | |
'surface', | |
'base', | |
'reading', | |
'pos', |
identifier: | |
guid: "129961" | |
fileName: "0129961.xml" | |
url: "http://query.nytimes.com/gst/fullpage.html?res=940DE4D9103CF930A15750C0A96E948260" | |
alternativeURL: | |
date: | |
publicationDate: "2004-09-03T00:00:00Z" | |
correctDate: "1987-02-04T00:00:00Z" | |
analyzed_text: | |
articleAbstract: "Gov James E McGreevey, ..." |
import re | |
import sqlite3 | |
class SQLite3DB: | |
_IDENTIFIER_RE = re.compile(r'^[a-zA-Z_]\w*$') | |
def __init__(self, filename): | |
self._con = sqlite3.connect(filename, isolation_level=None) | |
self._con.row_factory = sqlite3.Row |
>>> c1 = 1 + 1j | |
>>> c2 = 1 - 2j | |
>>> c1 + c2 | |
(2-1j) | |
>>> c1 * c2 | |
(3-1j) | |
>>> c1 / c2 | |
(-0.2+0.6j) |
$ pip install rstr |