月の列挙

Python で次の月を求めようとしたらメンドそうなので Ruby にした - YoshioriのBlog
2010-04-05 - atsuoishimotoの日記

僕がYoshioriのブログから読み取った要求仕様ではdatetimeもcalendarも必要な気がしないのでKeep It Simpleで:

year, month = 2005, 4

while (year, month) <= (2007, 04):
    print "%d%02d" % (year, month)
    month += 1
    if month == 13: 
        month = 1
        year += 1

って書いてみたのであった。いまの暦では閏月とかないから、毎年1~12の月があるだけだし。