Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
I recently rewrote my personal site using flask and peewee, breaking a good amount of stuff in the process. I was trying to track down the errors by tailing log files, but that didn't help alert me to new errors that someone visiting the site might stir up. I thought about setting up error emails a-la django, which is a tried and true method...but then I happened on a different approach. I won't s
Ruby、Perlときたので残るPythonについてもpythonbrewとvirtualenvで環境を整えてみた。いい加減内容がテンプレ的で飽きてきたけどw PythonもSnow Leopardでは2.6.1なので2.7とか3.2が使いたいよねーってことで。 タイトルには「Macで〜」って入ってるけど、pythonbrew自体はUNIX系の環境で使えます。 pythonbrewっていうのは、複数のPythonバージョンを簡単にインストールしたり切り替えたりできるようにするツールで、RubyでいえばRVM、Perlでいえばperlbrewみたいなもん。*1 これを使えばOS標準の環境も汚さないし、2.6系、2.7系、3系とかプロジェクトで使用中のバージョンと最新版とか色々な複数の環境を簡単に共存させて使い分けることができる。ステキ! pythonbrewを使うとこんな感じでサクサク環境を
ローカルのファイルシステムの監視。WindowsではGetDirectoryChangesW(だったっけ?)とかいうAPIがあって、Linuxにはinotifyがあるし、Macにもなにか手段があるはずなんだけど、 http://packages.python.org/watchdog/installation.html watchdog というライブラリを使えばAPIの違いを気にしないで監視できる。 watchdog すげー。 ファイルのアップロードとリモートでのコマンド実行。毎回scpコマンドを叩くのでも良いけど、 http://www.lag.net/paramiko/ paramiko というライブラリを使えば、常に ssh 接続を1本用意しておいてその上でファイルのアップロードもコマンド実行もできる。 paramiko すげー。 #!/usr/bin/env python impo
新年あけましておめでとうございます。昨年一年は自分の(体重の)成長を実感できて大変残念ですね。この野郎。今年一年は減量の方ももうちょっと頑張ろうな。俺。 というわけでタイトルの話です。既にSphinxドキュメントで「.rst」ファイルが更新されたら、自動的にビルドを走らせる方法は偉大なる先人達の手によってとっくに道が開拓されているのですが、あえてまた開拓したいと思います。というか他の方法を僕がちゃんと理解できなかったので、僕の知ってる一番簡単な方法でやってみました。 先人達の足跡 特にやり方が決まってるいる話ではないので、omakeが好きな人、Makefileだけでやりたい人とかは下記記事が参考になると思います。 OMakeでSphinxドキュメントをビルドする - 偏った言語信者の垂れ流し omake を使わずに、Sphinx ドキュメントの継続的ビルド: Addicted To Ind
はじめに この記事は、The decorator moduleの日本語訳です。TurboGearsの開発者はこのモジュールを参考にしたと、turbogears/decorator.pyに記述されています。 # Inspired by Michele Simionato's decorator library # http://www.phyast.pitt.edu/~micheles/python/documentation.html 諸元 作者: Michele Simionato E-mail: michele.simionato@gmail.com バージョン: 2.0.1 ダウンロード元: http://www.phyast.pitt.edu/~micheles/python/decorator-2.0.1.zip インストール方法: easy_install decorator
If you are not into long explanations, see Paolo Bergantino’s answer. Decorator Basics Python’s functions are objects To understand decorators, you must first understand that functions are objects in Python. This has important consequences. Let’s see why with a simple example : def shout(word="yes"): return word.capitalize()+"!" print(shout()) # outputs : 'Yes!' # As an object, you can assign the
python のデコレーター構文 @decorate 解り難い @decorate 構文 Python のデコレーターは理解するのが厄介です。Python のデコレーターは syntax sugar の機能と closure の機能の二つを使って関数オブジェクトを修飾する構文です。でも closure の概念がない C/C++ や Java などの 言語から python も使うようになった者に、三重にネストした関数と @decorator 構文を組み合わせたコード例を使って解説されたのでは脳みそが沸騰するだけです。 私は @decorator を使ったコード例の python virturla machine コードを追跡することで、やっとこさデコレーターを理解しました。私の味わされた苦労を軽減してもらうため、この web page をまとめてみます。 デコレーターを理解した後で考え直し
以下のメソッドを定義して、クラスインスタンスへの属性値アクセス ( 属性値の使用、属性値への代入、x.name の削除) の意味を カスタマイズすることができます。 属性値の検索を行った結果、通常の場所に属性値が見つからなかった 場合 (すなわち、self のインスタンス属性でなく、かつクラスツリー にも見つからなかった場合) に呼び出されます。 このメソッドは (計算された) 属性値を返すか、AttributeError 例外を送出しなければなりません。 通常のメカニズムを介して属性値が見つかった場合、__getattr__() は呼び出されないので注意してください。(__getattr__() と __setattr__() の間は意図的に非対称性にされています。 これは__getattr__() および __setattr__() 双方に とっての効率性という理由と、こうしなければ
この1ヶ月、土日の休みを使いTUBELONGERってWebアプリをつくってました。 言語はPython。 Pythonは日本語の取り扱いが若干面倒だったりするけど、書いてて楽なので好き。 以下、PythonでWebアプリをつくるにあたって調べたり分かったりしたことのメモ。 構成 OS:さくらVPS CentOS 5.5 サーバ:Nginx + Gunicorn データベース:MySQL 当初はGoogle App Engineで開発を進めてたけど、データストアの使い方を調べるのにいちいち時間をとられたり、Cron的な動作に制限があったりといろいろ面倒くさかったので、途中からroot権限のあるサーバでいちから構築する方向に切り替えました。 やっぱりroot権限は自由度が半端じゃないです。 GAEがダメってわけではないです。 むしろ僕の知識が足りなすぎて学習コストが尋常じゃなかったのでまた今度
I am attempting to install pycrypto (version 2.3) on OS X via pip. I am getting a "Broken pipe" error when the compiler attempts to compile MD2.c. I get a very similar error when using easy_install. Here is the error that I am getting: bash-3.2$ bash-3.2$ sudo pip install pycrypto Password: Downloading/unpacking pycrypto Running setup.py egg_info for package pycrypto Installing collected packages:
環境 Mac OS X 10.6.4 Python 2.6.6 Distribute 0.6.14 virtualenv 1.5.1 pip 0.8.1 Pythonをインストールする $ sudo port install python26 $ sudo port install python_select $ sudo python_select python26 Distributeをインストールする Distribute is a fork of the Setuptools project. http://packages.python.org/distribute 「エキスパートPythonプログラミング」を見るまで存在を知りませんでした>< $ curl -O http://python-distribute.org/distribute_setup.py $ sudo py
I am attempting to install Fabric, which requires pycrypto. During the build for pycrypto I always receive a "Broken Pipe" error. I don't know where to start to fix the problem. I'm running Mac OS X Snow Leopard 10.6.6, all updates installed; Python 2.6.1; GCC 4.2; XCode 4 (in case that updated GCC) The exact error is: $ sudo python setup.py build Password: running build running build_py running b
やったことをすぐに記録しないと後で絶対忘れるので、仕事中でも書く! 基本的に以前と同様にこちらで書かれていることをそのままなぞっただけなのですが、結構忘れることがありました。特に pymacs の使い方。こちら(その他に 1, 2)に書かれているようにropemacsも試してみましたが、こちらに書かれているようにやはりうまくいきませんでした。 まずは、setup.py と easy_install が通るようにします。 $ sudo port install py26-distribute $ sudo port install py26-pip 次に python-mode.el をインストール。ここからダウンロードして load-path の通った何処か(ヲイラは ~/.emacs.d/lisp)に置きます。.emacs.d/init.el には以下のように記載します。 (requir
移転しました http://please-sleep.cou929.nu/20110525.html
Beaker Documentation¶ Beaker is a library for caching and sessions for use with web applications and stand-alone Python scripts and applications. It comes with WSGI middleware for easy drop-in use with WSGI based web applications, and caching decorators for ease of use with any Python based application. Lazy-Loading Sessions: No performance hit for having sessions active in a request unless they’r
I’ve recently been looking into ways to improve my debugging experience with mixed Python and C/C++ programs. I spend a fair amount of time working on systems built using both languages in tandem, and the tools available for debugging across the languages have historically been very limited. Often, logging and/or intimate knowledge of the Python C-API (and, in my case, boost.python) were the prima
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く