wow! (generators) - suggestion (yield saved)
Roman Suzi
rnd at onego.ru
Sun Aug 5 03:49:53 EDT 2001
Hello!
The following code is from CGI script and provides way to have
nice calendar:
------------------------------------------------------------
from __future__ import generators
import calendar, string
def calt(year, month):
month_cal = calendar.monthcalendar(year, month)
yield """<B>%s.%s</B>""" % (month, year)
yield """<TABLE BORDER=1>"""
for week in month_cal:
yield """\n<TR>"""
for day in week:
yield """<TD>%s</TD>""" % (day or " ")
yield """</TR>"""
yield """</TABLE>"""
print string.join(calt(2001, 8), "")
--------------------------------------------------------
I like generators :-)
(Probably Python should use "black bullet" or "*" instead of "yield":
--------------------------------------------------------
from __future__ import generators
import calendar, string
def calt(year, month):
month_cal = calendar.monthcalendar(year, month)
* """<B>%s.%s</B>""" % (month, year)
* """<TABLE BORDER=1>"""
for week in month_cal:
* """\n<TR>"""
for day in week:
* """<TD>%s</TD>""" % (day or " ")
* """</TR>"""
* """</TABLE>"""
print string.join(calt(2001, 8), "")
----------------------------------------------------------------
What do you think?
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, August 05, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "By all means, let's not confuse ourselves with the facts!" _/
More information about the Python-list
mailing list