Skip to content

Instantly share code, notes, and snippets.

@cametan001
cametan001 / sample.py
Created May 23, 2011 23:50
関数型言語出身者が陥りやすいOOPの罠
cursor.execute("""SELECT lastname FROM people WHERE firstname = ? AND age = ?""", (name, age))
@cametan001
cametan001 / sample.ss
Created May 24, 2011 00:03
プログラムのデザイン
;; Contract(契約): area-of-ring : number number -> number
;; Purpose(目的): ドーナツ型の面積を計算する
;; 外側の円の半径をouter、内側の穴の半径をinnerとする
;; Example(例): (area-of-ring 5 3) は 50.24 を返す
;; Definition(定義): [何かマシな事をここに書く]
(define (area-of-ring outer inner)
(- (area-of-disk outer)
@cametan001
cametan001 / bad_import.py
Created May 24, 2011 00:18
wxPythonでハングマン
from Tkinter import *
@cametan001
cametan001 / actionIsLambda.py
Created May 24, 2011 00:30
wxPythonでハングマン_1
action = lambda e, x = ch, s = self: s.display(x)
@cametan001
cametan001 / buttonOnGrizSizer.py
Created May 24, 2011 00:41
wxPythonでハングマン_2
grid_sizer.Add(self.letters[ch], 0, wx.EXPAND, 0)
@cametan001
cametan001 / classWine.py
Created May 24, 2011 00:57
PythonでGUIアプリ第二弾
class Wine:
"""This class represents all the wine information"""
def __init__(self, wine = "", winery = "", grape = "", year = ""):
self.wine, self.winery, self.grape, self.year = wine, winery, grape, year
# end of class Wine
@cametan001
cametan001 / GTKNeedsToHave3LinesToDoAnAction.py
Created May 24, 2011 01:07
PythonでGUIアプリ第二弾_1
self.enWine = self.wTree.get_widget("enWine")
self.enWine.set_text(self.wine.wine)
self.wine.wine = self.enWine.get_text()
@cametan001
cametan001 / babyThisIsListComprehension.py
Created May 24, 2011 01:19
PythonでGUIアプリ第二弾_2
# Add all ot the List Columns to the wineView
[self.wineView.InsertColumn(cs.index(heading), heading) for heading in cs]
@cametan001
cametan001 / import_wx.py
Created May 26, 2011 13:58
おっさんにも解るwxPython
import wx
@cametan001
cametan001 / editConfig.py
Created May 26, 2011 14:13
おっさんにも解るwxPython_1
# 設定ファイルの書き換え
def editConfig(self, keyword, replaceString, configPath):
print keyword
print replaceString
# ファイルをオープン
f = open(configPath, 'r')
# 新しい書き込み用リストを生成
cnf = [txt.strip().find(keyword) >= 0 and replaceString + '\n' or txt \
for txt in [line for line in f.readlines()]]
f.close()