[Zope-dev] Re: [Zope] sequence of numbers

Bill Randle billr@coinet.com
Sat, 13 Mar 1999 08:37:13 -0800


Paul,

Thanks for the suggestion. I had thought of something like that, and my
sequence is short, but the problem is I don't know how long it is ahead
of time. The actual sequence length is stored in a property. I guess I
could brute force it like this:
	<!--#if "slen == 2"-->
	  <!--#call "REQUEST.set('foo'.['1','2'])"-->
	<!--#elif "slen == 3"-->
	  <!--#call "REQUEST.set('foo','['1','2','3'])"-->
	...
	<!--#/if-->

Before I finished writing this followup, I did some browsing thru the Python
book (definite newbie here, also) and found exactly what I was looking for:
	range(start?, end, step?)
So, what I want to do is:
	<!--#in "range(slen)"-->
	 // some stuff
	<!--/#in-->

I notice that range() is not in the list of attributes for '_'. Is there any
special reason for this? If it was there, I could do this:
	<!--#in "_.range(slen)"-->

Will it work to add "range" to the list of built-ins in line 185 of
lib/python/DocumentTemplate/DT_Util.py (line number matches version 1.50)?

I've redirected this followup to Zope-dev, as I think I'm talking more about
development issues now, than a simple language quesiton.

	-Bill Randle
	Central Oregon Internet
	billr@coinet.com


On Mar 13,  9:29am, Paul Everitt wrote:
} Subject: RE: [Zope] sequence of numbers
}
} Bill wrote:
} > What I want to do is given a limit number, iterate over a sequence of
} > DTML commands. This would be an obvious use for #in (which I'm using
} > elsewhere for other things) except I don't have a sequence - just the
} > number of items in the sequence, as it were.
}
} Here's a brute-force way to do it, as long as the list of items was
} short:
}
} <!--#call "REQUEST.set('foo',['1',
}                        '2','3','4','5'])"-->
}
} <!--#in foo-->
}   <!--#var sequence-item--><br>
} <!--#/in-->
}
} --Paul