[Baypiggies] Discussion for newbies/beginner night talks
Dennis Reinhardt
DennisR at dair.com
Sat Feb 10 05:46:45 CET 2007
At 08:28 PM 2/9/2007, Laszlo Antal wrote:
>Hi,
>This is a great thread.
>I want to thank everyone for sharing their wisdom.
>Keep it coming.
I *was* going to duck out because I was outnumbered by those favoring
triple quoting.
Yes, triple quoting can work for simple situations. The triple quoting
examples displayed in this thread have been just that: simple. They do not
include conditionally executed code or do parameter substitution. What
they do is obscure the block structure of the code.
Here is a code fragment from my talk last night (foil 15, I believe). How
would you re-write this to utilize triple quoting? The task here is to
build a two level visual tree structure:
# build entire initial tree structure
def init_tree(ht_obj):
html = "<table border=0>"
index = 0
last_exe = ""
for xml_entry in util_actwin.display_list("enm", "+"):
exe_name = str_extract(xml_entry, ["enm"])
keye = safe_int(str_extract(xml_entry, ["key"]))
act = str_extract(xml_entry, ["act"])
#logger("init_tree %s %s" % (keye, exe_name))
fname, exe = exe_name.split(".")
if fname != last_exe:
html += "<tr>"
if fname == expanded_node:
html += "<td><img src=image/slct32.gif border=0></td>"
else:
html += "\r\n<td><a
href=edt_main.py?slct=expand&fname=%s>" % fname
html += "<%s></a></td>\r\n" % hovered_img(ht_obj, index)
html += "<td><img src=%s width=32 height=32></td>" %
get_program_image(fname)
html += "<td>%s</td>" % fname
html += "<td> </td>"
html += "</tr>"
if fname == expanded_node:
html += "<tr>"
html += "<td> </td>"
parm_index = safe_int_default(ht_obj.param("index"), -1)
if parm_index == keye:
html += "<td><img src=image/slct32.gif border=0></td>"
html += "<td><img src=%s " % get_action_image(xml_entry)
html += "width=32 height=32 border=0></td>"
else:
html += "<td><a href=edt_main.py?slct=edit"
html += "&class=tree_open32"
html += "&index=%s" % keye
html += "&act=%s" % act
html += "><%s></a></td>" % hovered_img(ht_obj, index)
html += "<td><img src=%s " % get_action_image(xml_entry)
html += "width=16 height=16 border=0></td>"
html += "<td>%s</td>" % get_caption(xml_entry)
html += "</tr>"
else:
pass
last_exe = fname
index += 1
html += "</table>"
return html
---------------------------------
| Dennis | DennisR at dair.com |
| Reinhardt | http://www.dair.com |
---------------------------------
More information about the Baypiggies
mailing list