>>> import argparse >>> >>> def split_type(s): ... if ":" in s: ... return tuple(s.split(":", 1)) ... else: ... return s, 'zlib' ... >>> parser = argparse.ArgumentParser() >>> parser.add_argument('--send', type=split_type)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from sqlalchemy import ( | |
Column, | |
Integer, | |
ForeignKey, | |
Unicode, | |
) | |
from sqlalchemy.orm import ( | |
scoped_session, | |
sessionmaker, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import io | |
import argparse | |
import asyncio | |
import aiopg | |
import sqlalchemy as sa | |
import webob | |
from aiopg.sa import create_engine | |
from aiohttp.wsgi import WSGIServerHttpProtocol | |
from webdispatch import URLDispatcher, MethodDispatcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
{% for commit in commits %} | |
<li> | |
{{ commit.id}} {{ commit.message }} | |
</li> | |
{% endfor %} | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rst2latex --documentclass=ltjsbook --hyperref-options="unicode=true" --latex-preamble="\usepackage[ipa]{luatexja-preset}" book.rst book.tex | |
lualatex book.tex |
使い方の想定
schema.bind(query=DBSession.query(Person).filter(Person.gender=='male')
col=Person.first_name + " " + Person.last_name)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Babel==1.3 | |
Mako==1.0.0 | |
MarkupSafe==0.23 | |
Pillow==2.6.1 | |
SQLAlchemy==0.9.8 | |
WebDispatch==1.3 | |
WebHelpers2==2.0rc2 | |
WebOb==1.4 | |
WebTest==2.0.16 | |
beautifulsoup4==4.3.2 |
リストたちを入れる箱を作る
>>> values = {}
いろんな名前で空のリストを作る >>> varname = ('t1', 't2', 't3') >>> for vn in varname: ... values[vn] = [] ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def part_seq(seq, num): | |
""" | |
>>> list(part_seq(range(10), 5)) | |
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] | |
>>> list(part_seq(range(10), 3)) | |
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]] | |
""" | |
s = seq | |
while s: | |
f, s = s[:num], s[num:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install -t vendor webob webdispatch jinja2 | |
Collecting webob | |
Downloading WebOb-1.4.tar.gz (633kB) | |
100% |################################| 634kB 5.5MB/s | |
Collecting webdispatch | |
Downloading WebDispatch-1.3-py2.py3-none-any.whl | |
Collecting jinja2 | |
Downloading Jinja2-2.7.3.tar.gz (378kB) | |
100% |################################| 380kB 6.0MB/s | |
Collecting markupsafe (from jinja2) |