Python

今更ながら、「migrate your application to Python 2.7.」って言われてたのに対応してみる

Google App EngineのDashbordを見ると、下記の文言が毎回表示されていた。。。 A version of this application is using the Python 2.5 runtime, which is deprecated! The application should be updated to the Python 2.7 runtime as soon as possible, …

Google App Engineでnumpyを利用する

Python2.7より、いろいろなサードパーティライブラリを利用できる模様。 https://developers.google.com/appengine/docs/python/tools/libraries27?hl=ja 共円にて、行列計算が必要なため、実装してみたのでメモ。 とくに、numpy自体をインストールする必要…

属性が存在しない場合、デフォルト値を設定する

例:クラスKyouenPuzzleのリスト:puzzlesに動的に属性を付与します。 for p in puzzles: if 特定の条件: p.clear = '1' この状態で、p.clearにアクセスすると、例外が発生しました。 そのため、利用する際に下記のようにしました。 for p in puzzles: clear…

全てのHTMLリクエストをPythonで処理してから出力する

【宣伝】下記のページでも利用している技術です。 共円(http://my-android-server.appspot.com/) twitter連携などを行うと、ログイン状態や情報の取得など、全てのページで必要な処理が出てきました。 そのため、全てのHTMLリクエストをpythonのモジュール…

GAE/Pythonで、テンプレートを利用したHTMLの表示

http://〜.appspot.com/page/test.html などのURLをPythonのテンプレート機能を利用して表示する方法です。 app.yaml handlers: - url: /template/(.*) script: /template/\1 - url: /page/.* script: test.py 1つ目のurlでは、テンプレート用のHTMLファイ…