[Zope] newbie question - handling strings

Jim Washington jwashin@vt.edu
Mon, 27 Mar 2000 09:07:51 -0500


Hi, Dimitris

Dimitris Andrakakis wrote:
> 
> Hi there,
> I've got an 8-character string, say str='12345678'. With
> <dtml-var str> ofcourse I get 12345678.
> How can I display only part of it ? Say the first 4 chars
> (1234) or the next 2 (56) or the last two (78).
> In python I know this can be done with something like
> str[:4], str[4:6] and str[6:].
> Any help ? (Hope I didn't sound too newbish !).

If you want to use pythonish expressions in a dtml-var tag, just quote
them.

e.g., <dtml-var expr="myStr[:4]">  will get you the first four
characters of string myStr.  The 'expr=' part is optional.

-- 

Jim Washington
Center for Assessment, Evaluation and Educational Programming
Department of Teaching and Learning, Virginia Tech