2010-01-22から1日間の記事一覧

現在の timestamp と microsecond をつなげた文字列が欲しい

これで何かをするわけではないが、必要になったので書いた。 import datetime import time def __get_timestr_by_now(): now = datetime.datetime.now() micro_str = str(now.microsecond).zfill(6) time_str = str(int(time.mktime(now.utctimetuple()))) r…

文字列比較

気になったので比較して結果を確認した。 # -*- encode: utf-8 -*- if u'0' < u'1': print '0 < 1' if u'1' < u'2': print '1 < 2' if u'2' < u'3': print '2 < 3' if u'3' < u'4': print '3 < 4' if u'4' < u'5': print '4 < 5' if u'5' < u'6': print '5 <…

同じ値を複数の変数に代入する

もしかして邪道なのかな。 st1 = 'a' st2 = 'b' st3 = st4 = st1 print st1 # => 'a' print id(st1) # => 26430944 print st2 # => 'b' print id(st2) # => 26431008 print st3 # => 'a' print id(st3) # => 26430944 print st4 # => 'a' print id(st4) # =>…

指定したdatetime値でのfilter

ユーザー一覧の表示などする時には fetch() を使っていた。しかしこれでは1000件の壁にぶち当たる。そこで datetime 値での filter を使用した。 こんなモデルがあったとする from google.appengine.ext import db class Member(db.Model): insert_datetime …