Python

pythonからhiveserver2につなごうとしていろいろハマったのでメモっておく

CDH4.5のhiveserver2にpython 2.7+NOSASLでつなごうとしていろいろハマったのでメモっておきます。Setting Up HiveServer2 - Apache Hive - Apache Software Foundation をみると GitHub - BradRuderman/pyhs2をインストールして使えばいいようだがうまくい…

Fabricインストールメモ

Hadoopのような複数台のマシンを相手にする作業だと一括でコマンド発行したいことがあります。 その際に各マシンにいちいちSSHでログインして作業するのは面倒です。なのでその辺りを解決するツールが欲しくなります。Hadoop徹底入門だとparallel-sshが紹介…

virtualenvを使ったVistaでのTracプラグイン開発環境メモ

1. Python 2.6のインストール http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi をダウンロードしてインストールして環境変数PATHにC:\Python26, C:\Python26\Scriptsを追加する。2. easy_installのインストールhttp://peak.telecommunity.com/dist…

エキスパートPythonプログラミング

エキスパートPythonプログラミング作者: Tarek Ziade,稲田直哉,渋川よしき,清水川貴之,森本哲也出版社/メーカー: KADOKAWA/アスキー・メディアワークス発売日: 2010/05/28メディア: 大型本購入: 33人 クリック: 791回この商品を含むブログ (90件) を見るiPad…

Genshiのtag面白いね

TracでWikiMacroを作る場合はWikiMacroBaseを継承してexpand_macroを実装します。本家にあるサンプルだとこうですね。 from datetime import datetime # Note: since Trac 0.11, datetime objects are used internally from genshi.builder import tag from …

Pythonの__str__と__repr__

コメントもらったので試してみた。point.py """Point class This is the Point class """ class Point: __x = 0.0 __y = 0.0 z = 0.0 def __init__(self, x1, y1, z1) : self.__x = x1 self.__y = y1 self.z = z1 def toString(self) : return '(' + str(sel…

Pythonのdocstringとプライベート変数

いろいろ教えてもらったので復習がてらメモpoint.py """Point class This is the Point class """ class Point: __x = 0.0 __y = 0.0 z = 0.0 def __init__(self, x1, y1, z1) : self.__x = x1 self.__y = y1 self.z = z1 def toString(self) : return '(' +…

Topcoder過去問

http://sns.atfb.jp/view_diary/43/28802.html def count(a, b): """ >>> count(1, 5) 1 >>> count(6, 10) 1 >>> count(1, 10) 2 >>> count(1, 20) 4 >>> count(140, 150) 10 >>> count(170, 180) 10 """ count = 0 for i in range(a, b): if( str(i).find('…

10分でコーディング

10分でコーディング | プログラミングに自信があるやつこい!!をJava+Eclipseでやってみて1時間以上かけたあげく下記のプログラムの足下にも及ばなかった。。。orz 10分コーディングしてみた。 - When it’s ready. 10分間でコーディングにチャレンジ - …

MacでのTracプラグイン開発(WikiMacro編)

http://trac.edgewall.org/wiki/WikiMacros にあるようにHelloWorld.pyを作ってpluginsにおけばOK。簡単ですね。ただ動作確認するためにはログインしないといけないです。Apacheと連動させるのは面倒なので http://trac.edgewall.org/wiki/TracStandalone に…

MacでのTracプラグイン開発(PyDevでのデバッグ編)

PyDevの更新サイトは http://pydev.sourceforge.net/updates/であとはいろいろはまってあんま覚えてないんですが(汗)、とりあえずpython2.5でも2.6でも http://psyco.sourceforge.net/ をいれないとデバッグのときにエラーになるようです。ソースを書いた…

MacでのTracプラグイン開発(Hello World編)

いろいろはまったが以下でおけ(たぶん) 環境はMac10.5でPython2.5ね。MacPortは使わない。setuptoolsのインストール > wget http://peak.telecommunity.com/dist/ez_setup.py > python ez_setup.py Tracのインストール > sudo easy_install Trac プロジェ…

三角形と六角形

$ python Python 2.6.1 (r261:67515, Apr 26 2009, 20:50:46) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from turtle import * >>> forward(100) >>> left(120) >>> forw…

Python2.5からSQLiteが標準装備なんだ

使い方間違ってるかも知んないけどメモっとく。 import sqlite3 con=sqlite3.connect(':memory:') try: con.execute('create table person(name, age)') con.execute('insert into person values("hoge","11")') con.execute('insert into person values("pi…