The socket.io file socket.io.min.js can be retrieved from the socketio-client Github repository. Building the HTML Our HTML structure is fairly simple: there is a login pane at the top to set your and a two-column chat pane where the left column displays current users and the right column displays the chat: <h1>Socket.io Chatterbox</h1> <div id="status" class="border">Disconnected</div> <form id="
こちらのスライド。RubyでRubyを拡張する。つまりメタプログラミングの話。 Extending Ruby with Ruby // Speaker Deck メタプログラミングを使って他の言語の機能を実装しようという内容になってる。 Python: Function decorators Scala: Partial application Haskell: Lazy evaluation 今回は、この中でPythonのdecoratorを実装するというのをピックアップ。 githubにソースコードがあがってて、スライド中では未解決になってた問題がすでに解決されている。 michaelfairley/method_decorators ここから載せるコードは、githubの方じゃなくてスライド中のコードに一部手を入れたものになってる。ひとつのメソッドに複数のdecoratorを指定でき
主語を大きく括った割にバブル、挿入、クイックの三種類しか用意してないです。 参考:python - Updating a matplotlib bar graph? - Stack Overflow テンプレート import matplotlib import matplotlib.pyplot as plt import numpy as np from random import randint N = 60 # 配列の数 y = np.random.rand(N)*100 # ランダムな列をソートする # ここに処理を書く def animated_func(): ... # 描画更新 for rect, h in zip(rects, x): rect.set_height(h) fig.canvas.draw() ... fig = plt.figure() win = fig
環境を整える インストール Python2.7 pip virtualenv Python, virtualenv, virtualenvwrapper, Django and GAE のメモ - 牌語備忘録 - pygo git Heroku でアカウント取得しておく Heroku | Cloud Application Platform Heroku Toolbelt をインストール heroku コマンドを使えるようにする(以前は gem でインストールしてたような) Heroku Toolbelt Getting Started with Python on Heroku | Heroku Dev Center herokuにデプロイする手順 Getting Started with Django on Heroku | Heroku Dev Center 以前に作ったサンプルをつ
A couple years ago I wrote a rather flawed tutorial about SQLAlchemy. I decided it was about time for me to re-do that tutorial from scratch and hopefully do a better job of it this time around. Since I’m a music nut, we’ll be creating a simple database to store album information. A database isn’t a database without some relationships, so we’ll create two tables and connect them. Here are a few ot
承前:Pythonのデコレータ(decorator)を理解する 2 デコレータに引数を渡す 素晴らしい、ではデコレータ自身に引数を渡すにはどうしたらよいのだろうか? さて、デコレータは引数として関数を受け入れる必要があるのでちょっとやっかいだ。デコレータに直接デコレートされた関数-引数を渡すことはできないからだ。 解決を急ぐ前に、ちょっと復習をしよう。 # デコレータは'普通'の関数である def my_decorator(func): print "I am a ordinary function" def wrapper(): print "I am function returned by the decorator" func() return wrapper # そのため、なにも"@"など使わずに呼び出すことができる def lazy_function(): print "zzz
The Hitchhiker’s Guide to Python!¶ Greetings, Earthling! Welcome to The Hitchhiker’s Guide to Python. This is a living, breathing guide. If you’d like to contribute, fork us on GitHub! This handcrafted guide exists to provide both novice and expert Python developers a best practice handbook for the installation, configuration, and usage of Python on a daily basis. This guide is opinionated in a wa
承前:Pythonのデコレータ(decorator)を理解する 1 デコレータ詳説 先の例に対して、デコレータ構文を使うと次のようになる: @my_shiny_new_decorator def another_stand_alone_function(): print "Leave me alone" another_stand_alone_function() #出力: #Before the function runs #Leave me alone #After the function runs そう、これで全部、シンプルだ。@decoratorは単なる、 another_stand_alone_function = my_shiny_new_decorator(another_stand_alone_function) のショートカットにすぎない。Decoratorはデザインパ
StackOverFlow:Understanding Python decoratorsに対するe-satis氏によるデコレータの丁寧な解説。 一つエクスキューズしておくと、翻訳の作法とかよく分かってません。でも頑張ったつもり。つもり。 Imran氏による質問の内容 @makebold @makeitalic def say(): return "Hello" というデコレータに対して <b><i>Hello</i></b> という文字列を返すような関数ってどうやって書いたらいいの? e-satis氏による解説 Pythonの関数はオブジェクトである デコレータを理解するためには、まずPythonにおける関数がオブジェクトであることを理解しなければならない。このことは重大な影響をもたらす。なぜなのか簡単な例とともに見てみよう。 def shout(word="yes"): return
最近は、Pythonのテストフレームワークっていうとnoseがいいとか、py.testがいいとか色々聞きますが、Bazaarのテストライブラリはunittest + testtoolsベースなので、プラグインとかを作ろうと思うとその辺を使うことになります。 ある程度は我慢するとしても、parameterized testも書けない*1のはさすがに厳しいので、それっぽく書けるようにならないか試してみました。 で、書いてみたのがこれ。 parameterized.py 使い方はこんな感じ。 D:\TEMP\test>python test.py -v test_add1_A (__main__.TestSample) ... ok test_add1_B (__main__.TestSample) ... ok test_add1_C (__main__.TestSample) ... FAI
Seriously. This tutorial badly needs updating. Everything is in the book, and much, much more. It's also written in step-by-step tutorial form, it uses the latest django, and it really is free. No catch. What's the approach? Test-First! So, before we're allowed to write any real production code, we write some tests. We start by writing some browser tests - what I call functional tests, which simul
Raymond Hettinger @raymondh #python tip: The set.discard(k) method unconditionally removes k from a set. For dictionaries, use dict.pop(k, None). 2011-05-03 05:18:53 Raymond Hettinger @raymondh #python tip: The fast itertools recipes can be copied to a utils module with a single cut-and-paste. http://bit.ly/itertools_plus 2011-05-13 23:54:45
The Python installation includes an interactive interpreter that you can use to execute code as you type it. This is a great tool to use to try small samples and see the result immediately without having to manage output or print statements. If you have not done it yet, download the lab files at the following URL: https://marakana.com/static/student-files/python_fundamentals_labs.zip(Linux / Mac)
pythonとりあえず自分用に。あとでちゃんとまとめ直す...かも。コマンドh(elp) [command]コマンドのヘルプを表示引数なしで利用可能コマンド一覧を表示s(tep)一行実行(ステップイン)n(ext)一行実行(ステップオーバー)unt(il)(Python2.6から)行番号が現在行より大きくなるか、現在のフレームから戻るまで実行r(eturn)returnされるまで実行(ステップアウト)c(ontinue)次のブレークポイントまで実行j(ump) lineno次に実行する行を指定最も底のフレームでのみ実行可能forやfinallyなどの中には飛び込めないl(list) [first[, lastソースコードを表示引数なし 前後11行引数一つ その行から11行引数二つ 与えられた範囲行a(rgs)現在の関数の引数リストをプリントp expression現在のコンテキストでexp
はじめに こんにちは、Python界の情弱です。最近は色々とPythonの開発環境も変化してきていて、ようやくPython2.xとPython3.xを行き来しながら開発する体制が整ってきたという印象を受けています。ここしばらくは色々と試していたのですが、ようやく鉄板っぽい方法にたどり着いたのでメモしておきます。 なお、後半はPythonに限らない内容なので、他のLLを使っていても使えそうかなと思っています。この環境を設定すると何ができるのかというと、以下のことすべてが、無料で、自鯖を立てることなく行えます。 開発環境の整理(virtualenv) ローカルでの複数環境のテスト容易化(tox+pytest) CIによるテスト(Travis-CI) ドキュメントの自動ビルドおよびドキュメントの公開(ReadTheDocs) 概要 とりあえず全体像を先に共有しておきます。ちょっとでかいですがご了
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く