Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
~/Documents/.../python/numpy $ ipython git[branch:master] from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifierPython 2.7.3 (default, Apr 13 2012, 00:05:08) Type "copyright", "credits" or "license" for more information. IPython 0.13 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help sy
トリビアルな例だが、元の関数(func)をデコレート・ラップするmydecoratorというデコレータを書いた時、下のように単純にinnerを返すと、 def mydecorator(func): def inner(*args, **kwds): print "Hi, I'm inner!" return func(*args, **kwds) return inner @mydecorator def hello(to): """ Say hello to somebody """ print "Hello, %s!" % to if __name__ == '__main__': print repr(hello) print hello.__doc__ 結果として、 None のように、デコレートされた元の関数(hello)の関数名やドキュメント文字列が失われてしまう。デコレータを
Python was created by Guido van Rossum in the early 90s. It is now one of the most popular languages in existence. I fell in love with Python for its syntactic clarity. It's basically executable pseudocode. # Single line comments start with a number symbol. """ Multiline strings can be written using three "s, and are often used as documentation. """ ################################################
会社のエンジニアブログを書いていて、あまりにもアメブロのエディタがしんどかったのでカッとなって作ってしまった。これでエンジニアブログ書くのが捗ると思う。heroku上のサンプルはここ。 使った技術 Python 2.7 misaka - MarkdownをHTMLに変換するライブラリ heroku herokuはGitリポジトリにpushするだけでディプロイ出来て便利だなーと思った。 パーフェクトPython (PERFECT SERIES 5) 作者: Pythonサポーターズ 出版社/メーカー: 技術評論社 発売日: 2013/03/05 メディア: 大型本 購入: 1人 クリック: 65回 この商品を含むブログ (8件) を見る
日付周りの処理というのはとても難しい問題で、特にTimeZoneが絡むと基本的に大変なことになります。 Pythonは標準で用意されているdatetimeモジュールが高機能なので、それを使っておけば間違いない感があって、そういう意味では安心感があります。 とは言え、その扱いにはやはり注意が必要で、現時点でこうするのがいいかなーと思っていることをつらつらと記録したエントリがこちらです。 基本的にはMacのPython2.7.1で検証して、おやっと思ったところはCentOS5.8のPython2.6.5やUbuntu12.04のPython2.7.3で追試しています。 なお、datetime.datetimeと書くのがだるいので本文中では、 from datetime import datetime を前提としています。 naiveとaware 公式ドキュメントにそのまま載ってるけど、date
Python debugging tools 05 June 2013 (updated 17 February 2016) This is an overview of the tools and practices I've used for debugging or profiling purposes. This is not necessarily complete, there are so many tools so I'm listing only what I think is best or relevant. If you know better tools or have other preferences, please comment below. Logging * Yes, really. Can't stress enough how important
※ポートを自動で選ぶ方法について、Arduino Microでも動くスクリプトを追記しました Arduonoは単体で遊ぶよりパソコンとシリアルで接続してこそだと思います。書籍「Arduinoをはじめよう」でArduino側でのシリアル通信について書かれてますので、ここではパソコン側について書いてみます。 そもそもpyserialを使えるようにする WindowsはPythonに限らず、RubyとかPerlとか最新版に追随してない場合も多々あるので、あくまで今の時点の動かし方ということで。ちなみに当方はWindows7 64bit。それ以外は、よくわかりません。 Python本体は公式の2.7.3。 http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi PySerialは、こちらの非公式ビルドからpyserial-2.6.win32-
PerlでいうところのTest::TCP相当のことをPythonでやるライブラリをPyPIに上げました。ようやくPyPIデビューです。 https://github.com/nekoya/python-tcptest https://pypi.python.org/pypi/tcptest Test::TCPはPerlでテスト時に一時的にサーバを起動したりする処理の基盤となるライブラリです。同等のことをPythonでやるのに適当なものが見当たらなかったので自分で書いたという経緯です。 社内では以前からこの仕組みを使ってテストを書いていたのですが、自社のconfig系のライブラリとの結合を排除して、再構成したものになります。今回こうして公開するにあたって、関数名をオリジナルのPerl版に近付けたり、TestServerの実装を全面的に見直したりしました。 tcptestパッケージにはTest
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く