This file contains hidden or 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
""" | |
`wired` (と、それを使う `pyramid_services`) で | |
`iface` に `Protocol` を使うと `isinstance` が使えなくなるメモ | |
たぶんwiredでなくてもクラスに何かを書き込むようなライブラリは | |
同じ理由で意図した動作にならないんだろう | |
""" | |
from typing import Protocol, runtime_checkable |
This file contains hidden or 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
#!/bin/bash -x | |
mkpkg() { | |
name=$1 | |
shift | |
deps="$*" | |
mkdir -p $name/$name | |
touch $name/$name/__init__.py | |
cat > $name/setup.py <<EOF | |
from setuptools import setup |
This file contains hidden or 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
"""zope.interface provides an attribute with a type annotation for classes | |
(requres: python 3.6) | |
""" | |
import typing | |
import zope.interface | |
class IFoo(zope.interface.Interface): | |
f_str: typing.Text = zope.interface.Attribute('String Attr') | |
f_str_opt: typing.Optional[typing.Text] = zope.interface.Attribute('Optional String Attr') |
This file contains hidden or 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
"""zope.interface provides an attribute with a type annotation for classes | |
(requres: python 3.6) | |
""" | |
import typing | |
import zope.interface | |
class IFoo(zope.interface.Interface): | |
f_str: typing.Text = zope.interface.Attribute('String Attr') | |
f_str_opt: typing.Optional[typing.Text] = zope.interface.Attribute('Optional String Attr') |
This file contains hidden or 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: utf8 -*- | |
from __future__ import print_function | |
import sqlalchemy as sa | |
from sqlalchemy.orm import backref, joinedload, relationship, subqueryload | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() |
This file contains hidden or 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: utf8 -*- | |
from __future__ import print_function | |
import sqlalchemy as sa | |
from sqlalchemy.orm import backref, joinedload, relationship, subqueryload | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() |
This file contains hidden or 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 -*- | |
# http://flask.pocoo.org/docs/quickstart/#a-minimal-application | |
# から | |
# http://flask.pocoo.org/docs/quickstart/#variable-rules | |
# までを写経していくと | |
from flask import Flask | |
app = Flask(__name__) |
This file contains hidden or 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 -*- | |
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/ | |
# から抜粋 | |
from wsgiref.simple_server import make_server | |
from pyramid.config import Configurator | |
from pyramid.response import Response | |
def hello_world(request): |
This file contains hidden or 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 -*- | |
from flask import Flask | |
from werkzeug.exceptions import NotFound | |
from jinja2 import Template | |
import sqlite3 | |
app = Flask(__name__) | |