2006-05-26から1日間の記事一覧

Windows の Explorer のようなソートを行うための比較関数

def intelligentcompare(s1, s2, ignorecase = False): """\ This function automatically detects numerical string for intelligent comparison. >>> cmp('2. a title of 2nd chapter', '10. a title of 10th chapter') 1 >>> intelligentcompare('2. a ti…

数値を通貨としてフォーマットされた文字列にする

途中にとんでもないコードがあるけど気にすることはない import locale, operator def currencyformat(currency, i18n = False, conv = {}): localeconv = locale.localeconv() localeconv.update(conv) conv = localeconv cs = ((not i18n) and (conv['curr…