[Zope] list access

Casey Duncan cduncan@kaivo.com
Wed, 07 Mar 2001 08:15:04 -0700


Axel Missbach wrote:
> 
> Hello,
> please tell me how access an list member in a dtml-Method/ Document.
> 
> per Example, having a list numbers[7,11,13,17,19]. How to get the first
> item?
> 
> <dtml-var numbers[0]> results in a KeyError! Why?
> 
> greetings
> Axel
> 

<dtml-var numbers[0]> is equivilant to <dtml-var name="numbers[0]">.
What you are writing is a (short) expression. Try:

<dtml-var expr="numbers[0]">

You have stumbled upon the reason why the shorthand notation: <dtml-var
x> and <dtml-var "x"> is discouraged in favor of <dtml-var name="x"> and
<dtml-var expr="x"> respectively. They may be longer, but they are much
more explicit.

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>