[Zope] basic python -> dtml translation.

chas panda@skinnyhippo.com
Mon, 13 Sep 1999 06:26:39 +0800


>> trivial no doubt, but buggered if i can find the python
>> equivalent for "eval". eg. how would you rewrite this in
>> dtml :
>>
>> for i in range(1,6) :
>>         print (eval('var%s' % i))
>>
><dtml-in "_.range(1,6)">
>  <dtml-var "_['var'+_['sequence-item']]">
></dtml-in>
>
>or, since you're a PythonMethods fan,
>
>for i in range(1,6):
>  print _['var%s' % i]

Thanks for the help - this second snippet is nice and concise
and I think demonstrates the power of PythonMethods : (1) using 
Python as the framework whilst being able to call Zope objects
and (2) greater readability of code ... although I may be a 
little biased there <g>.

Btw, I'd just like to clarify my earlier comments : DTML is OK
perhaps for content authors/teams so I was not meaning to rag on 
it. But I've accomplished more in the past 6 hours than 
in the previous 4 days by moving all logic to PythonMethods
and feel MUCH better about building apps now.


>Thanks for the kudos, by the way.  As for the use of tabs in
>PythonMethod code, my advice is: DON'T.  Hit the spacebar 2 or 4 times
>instead; you'll be glad you did. 

Cool. Did I miss a technote on this ? Coming from Python, others
might assume that tabs are needed.

cheers,

chas