10.7. itertools — 効率的なループ実行のためのイテレータ生成関数¶ バージョン 2.3 で追加. このモジュールではイテレータ(iterator)を構築する部品を実装しています。 プログラム言語 APL, Haskell, SML からアイデアを得ていますが、 Python に適した形に修正されています。 このモジュールは、高速でメモリ効率に優れ、 単独でも組み合わせても使用することのできるツールを標準化したものです。 同時に、このツール群は “イテレータの代数” を構成していて、 pure Python で簡潔かつ効率的なツールを作れるようにしています。 例えば、SML の作表ツール tabulate(f) は f(0), f(1), ... のシーケンスを作成します。 このツールボックスでは imap() と count() を用意しており、 この二つを組み合わせて i
Overview Epydoc is a tool for generating API documentation for Python modules, based on their docstrings. For an example of epydoc's output, see the API documentation for epydoc itself (html, pdf). A lightweight markup language called epytext can be used to format docstrings, and to add information about specific fields, such as parameters and instance variables. Epydoc also understands docstrings
これは Python3 Advent Calendar の記事です。夢はテストエンジニアです!ということでユニットテストについて書きます。 Python3 縛りとのことですが、この新ユニットテストフレームワークは Python 3.2 以降と 2.7 以降が対象です。これ以前のバージョンでこの新ユニットテストフレームワークを利用したい場合は、それぞれ unittest2py3k (3 系)、 unittest2 (2 系) というバックポートが用意されています。新ユニットテストは mock や IronPython 等の開発者としても知られている Michael Foord 氏を中心に開発されました。 >>> Python とユニットテストの歴史 Python のユニットテストは、1999 年 xUnit ファミリーの PyUnit として開発され、2001 年に公開された Python
https://github.com/amoffat/Inspect-Shell 試しにdjangoの開発サーバにシェルを組み込んでみよう。 views.py # -*- coding: utf-8 -*- from django.http import HttpResponse, HttpResponseRedirect data=dict(msg='OH HAI', inspect_shell_imported=False) def inspect_shell(request): """ inspect_shellをテストするページハンドラ GETするとdata['msg']が出力される。 """ # モジュールレベルでインポートするとワーカープロセスじゃなくてその親で # inspect shellが走ってしまう。viewハンドラが呼ばれたときにインポートする # ことによってHTT
PythonでBasic認証する方法をWebで調べてみると、たくさんの記事が見つかりました。 標準ライブラリだけでできるのですね。すばらしい。 #!python # -*- coding: utf-8 -*- import urllib2 # ユーザ名とパスワードを登録する password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() password_mgr.add_password(None, 'http://~', 'ユーザ名', 'パスワード') # 認証情報付きでアクセスする handler = urllib2.HTTPBasicAuthHandler(password_mgr) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) f = u
‐ programming, open source, os, and a handful of tips Pythonでは、HTTPやFTPなどでファイルの送受信をするモジュールとして「urllib」と「urllib2」が用意されている。使い方も似ていて、どちらも引数としてURLを与えてurlopen()関数を呼び出すと自動的に対応したプロトコルでURLにアクセスしてデータを読み出せる、というものである。しかし、似たような名前で似たような機能を持つこの2つ、何が違うのかが明確にはドキュメントに記述されていない。そのためどちらを使うべきか迷って、そのたびにGoogleのお世話になるという状況だったのでざっとまとめてみよう。 外から見える違いとしては、urlopen()の引数としてurllibはURL文字列のみを受け付けるのに対し、urllib2ではurllib2.Requestクラスを受け
https://github.com/gruns/furl インストール $ git clone https://github.com/gruns/furl.git $ cd furl $ ls API.md furl.py furl.pyc LICENSE.md README.md tests/setup.pyなどはない。 python2.7以上 python2.6でも使えるようにしたフォーク:https://github.com/tengu/furl $ python Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from furl impor
Python Remote Objects 4.x Pyro is a library that enables you to build applications in which objects can talk to each other over the network, with minimal programming effort. You can just use normal Python method calls, with almost every possible parameter and return value type, and Pyro takes care of locating the right object on the right computer to execute the method. It is designed to be very e
実践的な DJango テクニック集として、凄くいい記事だったので、勝手に超訳してみました。 http://zeroandone.posterous.com/top-10-tips-to-a-new-django-developer 1. import にプロジェクト名を書かないこと 例えば "project3" というプロジェクトに "xyz" アプリケーションがある場合、次のようにはしないこと。 from project3.xyz.models import Author これではプロジェクトとアプリケーションの結びつきが強すぎて、以下の弊害がおこる。 アプリケーションの再利用がしづらい 将来プロジェクト名を変えたくなっても変更が難しい なので、このようにしよう。 from xyz.models import Author python パス上にある django プロジェクトならば、
< The New Hot Thing in Web Development: Client-side Templating Languages (13) Thu Dec 08 2011 05:02 Python 2.8: +1: Armin Ronacher bravely shares his thoughts on Python 3. He also says: "Can we reopen the option of doing a Python 2.8 if it makes porting easier?" A big +1 from me. Declaring that a Python 2.8 is never going to happen is just bizarre from my perspective. What is this supposed to acco
渋日記@shibu.jp 渋川よしきの日記です。ソフトウェア開発とか、ライフハックを中心に記事を書いていきます。 今出張で、サン・フランシスコに来ています。街はもうクリスマスムードで、楽しげな雰囲気がただよっています。期間限定のアイススケートのリンクが公園にできていたり、ngmoco:)のオフィスの入っているビルにもイルミネーションが飾られていたりします。 PyPy advent calendar に参加しています。@aodagからバトンを受け取りました。今日のこのネタはアドベントカレンダーの記事です。 PyPyはご存知でしょうか?その怪しげな(Pythonらしくイヤラシい)名前にもかかわらず、なんだかよく分からないパフォーマンスを叩き出しているPython処理系です。1.6でもすでにCPythonよりも早かったのですが、1.7ではさらに改善されています。 ですが、このPyPyよりも速いP
Thoughts on Python 3 written on Wednesday, December 7, 2011 I spent the last couple of days thinking about Python 3's current state a lot. While it might not appear to be the case, I do love Python as a language and especially the direction it's heading in. Python has been not only part of my life for the last couple of five years, it has been the largest part by far. Let there be a warning upfron
Monitoring Agent¶ The Amon Agent is a small piece of software that runs on your hosts. Its job is to collect metrics and bring them to Amon so that you can do something useful with your monitoring and performance data. These pages describe how to configure and run the Amon agent Installing the agent Agent configuration Running the agent Testing the agent Manual install Plugins¶ These pages describ
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く