ブログ パスワード認証 閲覧するには管理人が設定した パスワードの入力が必要です。 管理人からのメッセージ maintenance 閲覧パスワード Copyright © since 1999 FC2 inc. All Rights Reserved.
ブログ パスワード認証 閲覧するには管理人が設定した パスワードの入力が必要です。 管理人からのメッセージ maintenance 閲覧パスワード Copyright © since 1999 FC2 inc. All Rights Reserved.
訂正:コードがクロージャではなかったので書き直してみた クロージャは、プログラミング言語において引数以外の変数を実行時の環境ではなく、自身が定義された環境(静的スコープ)において解決する関数のことである。関数とそれを評価する環境のペアであるともいえる クロージャ - Wikipedia う〜んよくわからん(´・ω・`) 例(javascript) function newCounter() { var i = 0; return function() { // 無名関数 i = i + 1; return i; } } c1 = newCounter(); alert(c1()); // 1 alert(c1()); // 2 alert(c1()); // 3 alert(c1()); // 4 alert(c1()); // 5 クロージャ - Wikipedia Python 『Py
View popular, latest, top-rated or most viewed Feed of the popular Python recipes Python Versions All Python 2 recipes All Python 3 recipes Top-rated recipes Decorator for BindingConstants at … (Python) Infix operators (Python) Spreadsheet (Python) Named Tuples (Python) Linear equations solver in 3 lines (Python) Singleton? We don't need no stinki… (Python) Send an HTML email with embedded i… (Pyt
VisualStudioIDE上でどうしてもPythonしたくなったので、メモ。 まずは、IDEの受け入れ準備。 VisualStudio2008Shell(integratedMode)ServicePack1再頒布可能パッケージ 言語統合に必要らしい。 VisualStudio2008SDK1.1 VisualStudio拡張SDK IronPythonStudioIntegratedSetup IronPythonStudio本体(integratedを選択) IronPythonStudio 入れた後、WPF しかプロジェクトが無い場合、のメモは以下の通り。 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\IronPython Studio のディレクトリを、そのまま C:\User
2012年9月追記 記事執筆当時から比べると,主に著名なパッケージやモジュールのPython 3対応が進んできており,そろそろPython 3への移行を考えてもよい頃かもしれませんね:-)。 ちょっと宣伝。Pythonの最新版に対応した入門書「みんなのPython 第三版」,発売中です:-)。 2008年のリリース当時,Python 3.0は完全に普及するまで数年かかるだろうと言われていて,僕も実際に仕事で3.x系をバリバリ使うようになるのは何年か先になるだろうと思っている。 最も大きな理由。それはCで書かれたエクステンションの3.0対応がけっこう大変だから。 エクステンション開発者を悩ませるのは,組み込み型の変更だろう。このへんに書かれていることを読むと分かるけど,3.0では文字列型,数値型のC構造体の名前が変わってしまうのだ。Cのソースコードでは,構造体を利用している部分を全部見て,書
July 19, 2008 Using Facebook’s Thrift with Python and HBase Today I’m going to show you how to interface Python to Apache HBase using Facebook’s Thrift package. Hbase is a documented oriented database which is very similar to Google’s BigTable (in fact its more or less a clone of BigTable as seen in the BigTable paper). HBase has two primary interfaces - a REST API which is relatively slow, and a
2009/03/11 19:30から行われたPython Code Reading 08 お題 標準ライブラリに学ぶ Python 3.0 移行のポイント by ふるかわとおる氏 内容的には、Python 3 に移行した際に、発生するであろうトラブルや、どのように移行すべきか、問題を直すべきか、といったものです。 個人的にとてもとてもニーズのある話題で、ブラボーブラボーな感じです。 Python Code Readingに参加するような層のメンバーには、必要になることも多いでしょう。 Python 3.0 のベネフィット より分かりやすくPythonのコードを書けるようになった あるべき形に、3.0へのメジャーバージョンアップにともない移行した Python 3.0 のデメリット 後方互換性がない 結果、動かなくなるコードが多数でてしまう。 動かなくなったコードを修正するには print文
Here is a quick hack that I wrote. It's a Python library to search Google without using their API. It's quick and dirty, just the way I love it. Why didn't I use Google's provided REST API? Because it says "you can only get up to 8 results in a single call and you can't go beyond the first 32 results". Seriously, what am I gonna do with just 32 results? I want to automate my Google hacks and I wan
PageRank とか HITS といったリンク解析ではグラフの計算が頻発するのだが、Python でそのあたり書くときの話をまとめてみる。グラフは行列で表現できる(ノード×ノード次元の行列 A を考えて、ノード i からノード j にエッジがあるとき、A[i,j] に値を入れておけばよい。無向グラフのときは A[i,j] = A[j,i] なので対称行列になる)ので、要は行列を手軽に扱えるライブラリの紹介である。 実は Python の行列演算ライブラリはどれも lapack/blas を内部的に呼んでいるので、C/C++ 等と比較してもそんなに遅くない。それどころか、自動的に並列化できるところは並列化してくれたりするので、まれに C より速いこともあるらしい。特に巨大なグラフを作る場合、ほとんどの処理は C などで書かれた関数に飛ぶので、速度的な問題は無視してもいいくらいである(逆に、
http://d.hatena.ne.jp/Yamashiro0217/20090310/1236674979 のはてぶのタグに何故か Python タグがあったので、 これは Python で書けって事かなぁと思って書いてみました。 import sys,os,urllib,time;[[[globals().__setitem__('url','http://www.bijint.com/jp/img/photo/%02d%02d.jpg' % (i, j))] and [globals().__setitem__('file',open(os.path.basename(url), 'wb'))] and [file.write(urllib.urlopen(url).read())] and [file.close()] and [time.sleep(5)] for j in r
088:多次元配列をループする 2次元のリストの全要素にアクセスするには二重の for 文を用います。次のコードは 3x3 のリストの全要素にアクセスする例です。 >>> L2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> for x in L2: ... for y in x: ... print y ... 1 2 3 4 5 6 7 8 9 次元が増えた場合も、同様に for 文を増やしていくことで取り出すことができます。 3x3x2 のリストの例です。 >>> L3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]] >>> for x in L3: ... for y in x: ... for z in y: ... print z ... 1 2 3 4 5 6 7 8 9
原点に戻る。plyでminilispを実装します。 紹介の意味も込めて某所にあったのをほぼそのまま載せます。 plyのシンプルさ(Lispのシンプルさ?)がわかってもらえるかと思います。 minilisp_lex.py import ply.lex as lex tokens = ('QUOTE', 'SIMB', 'NUM', 'LPAREN', 'RPAREN', 'NIL', 'TRUE', 'FALSE', 'TEXT') reserved = { 'nil' : 'NIL', } t_LPAREN = r'\(' t_RPAREN = r'\)' t_QUOTE = r'\'' t_TRUE = r'\#t' t_FALSE = r'\#f' def t_NUM(t): r'\d+' try: t.value = int(t.value) except ValueError: p
Welcome to the PLY homepage. PLY is an implementation of lex and yacc parsing tools for Python. If you don't have the slightest idea what that means, you're probably in the wrong place. Otherwise, keep reading. In a nutshell, PLY is nothing more than a straightforward lex/yacc implementation. Here is a list of its essential features: It's implemented entirely in Python. It uses LR-parsing which is
1 ctypesによるDLL内の関数の呼び出し ctypesモジュールとは、Cデータ型をPythonで生成・操作したり, DLL内の関数を呼び出したりするためのモジュールである。 以下、DLL内の関数を呼び出してみる。 >>> from ctypes imoprt * >>> cdll.msvcrt.printf('Hello, world!\n') Hello, world! 14 >>> cdll.msvcrt.printf('double value: %f', c_double(3.14)) double value: 3.14000022 cdllではcdecl呼び出し規約を使い、上記でprintf()関数が呼び出される。 また、Pythonの整数型、文字列型、unicode文字列型以外の型はCデータ型に変換できるように 対応するctypes型でラップする必要がある
NAIST の入学手続を終えた. 残りの期間はサーベイするぞーということで shimbo 先生の講義資料「リンク解析とその周辺の話題」を読んでいます. 一日目, 二日目の資料は PageRank, HITS, SALSA などの重要度尺度の紹介と, von Neumann Kernels と HITS の関係についてのお話が中心. これらを実装してみた. 後半に進むほど力尽きて記述が適当になってます:)PageRankポイントはランダム遷移行列による random walk では定常分布に収束しない (エルゴード性 (ergodic) を満たさない) という点. どうして満たさないかというと. sink (出次数のない節点) が存在するとき, 明らかに既約 (irreducible) でないのでエルゴード性を満たさない. 複数の強連結成分を持つケース => 周期性を持つと考えてよい? 周期
Introduction This phrasebook contains a collection of idioms, various ways of accomplishing common tasks, tricks and useful things to know, in Perl and Python side-by-side. I hope this will be useful for people switching from Perl to Python, and for people deciding which to choose. The first part of the phrasebook is based on Tom Christiansen's Perl Data Structures Cookbook. I have only been worki
なんか色々方法はあるのですが、準備がめんどくさかったので MozRepl 使って自分でさくっと #!/usr/bin/env python # -*- coding: utf-8 -*- import sys,os,telnetlib,time class MozRepl: def __init__(self, host='localhost',port=4242): self.tn = telnetlib.Telnet(host,port) self.tn.read_until("repl>") def reload(self): self.tn.write('content.location.reload(true)') def close(self): self.tn.write('repl.quit()') self.tn.close() def getMtime(filename
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く