Such is a DSL for writing tests with expensive, nested fixtures – which typically means functional tests. It requires the layers plugin (see Organizing Test Fixtures into Layers). What does it look like? Unlike some python testing DSLs, such is just plain old python. import unittest from nose2.tools import such class SomeLayer: @classmethod def setUp(cls): it.somelayer = True @classmethod def tea
2014/03/05 01:40 ※ 商品のリンクをクリックして何かを購入すると私に少額の報酬が入ることがあります【広告表示】 なんとなくわかってたけど思いのほか… (33default) makoto@mba $ python -m memory_profiler d.py Filename: d.py Line # Mem usage Increment Line Contents ================================================ 4 9.707 MiB 0.000 MiB @profile 5 def a(): 6 9.711 MiB 0.004 MiB d = {} 7 11.027 MiB 1.316 MiB for i in range(10000): 8 11.027 MiB 0.000 MiB d[i] = str(i) 9
ロギングの環境設定 という公式ドキュメントにも警告があったのですが、思いっきりハマってしまったので記事にしておきます。 Python の logging モジュールは、 addHandler() などのメソッドを呼び出して構成する以外に、 ini 形式の設定ファイルを元に構成する logging.config.fileConfig() や、 dict 型の設定情報を元に構成する logging.config.dictConfig() を使って構成することができます。 import logging.config logging.config.dictConfig({ 'version': 1, 'handlers': { 'default': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'stream': 'ext://sys.
Web scraping is one of those subjects that often appears in python discussions. There are many ways to do this, and there doesn't seem to be one best way. There are fully fledged frameworks like scrapy and more lightweight libraries like mechanize. Do-it-yourself solutions are also popular: one can go a long way by using requests and beautifulsoup or pyquery. The reason for this diversity is that
ふとDive Into Python 3を読んで、重い腰を上げて今後はなるべく Python 3 環境で働くべく、 Python 2.7 / 2.6 な環境で今やっているプロジェクトを Python 3.3.4 の環境に置き換えてみました。 ちなみに今やっているプロジェクトが使っている外部ライブラリは Welcome | Flask (A Python Microframework) SQLAlchemy - The Database Toolkit for Python Flask-SQLAlchemy と、それらが依存するライブラリ(例えばJinja2)なのですが、どれもすでに Python 3 対応してそうなので踏み切りました。 多少大変ではあったものの、内容としては大したこと無くて変更が多かったのはほとんどが文字列周りでした。具体的には以下のような感じ。 文字列・ユニコード・バイト
Pythonの文法チェックツールFlake8をVimから使うプラグインのインストールと設定方法です。 VimからFlake8を使うためのプラグインはいくつかありますが、自分が使っているSyntasticとvim-flake8を紹介します。 VimプラグインのインストールにはNeoBundleを使用しています。NeoBundleのインストール方法はここでは書きませんが、高機能でとても便利です。 Syntastic https://github.com/scrooloose/syntastic Syntasitcは外部の構文チェッカーを使用して構文チェックを実行しVim上に結果を表示してくれるプラグインです。Pythonだけでなく色々な言語の構文チェッカーを使うための設定も用意されています。 インストール .vimrcに下記の設定を追加し、:NeoBundleInstall を実行します。
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く