[Zope] tal expression

Tino Wildenhain tino at wildenhain.de
Thu Nov 4 04:41:27 EST 2004


Hi,

On Thu, 2004-11-04 at 09:57, Garito wrote:
> Garito wrote:
> 
> > Hi
> > will these be possible?
> >
> > <tal:b tal:define='dictionary python: {"value1": ["one", "two", 
> > "three"], "value2": "two", "value3": "three"}'>
> >    <tal:b tal:replace='python: dictionary["value1"][5] | "Value not 
> > available"' />
> > </tal:b>
> >
> > Obviously these is an incorrect tal expression (the replace one) but 
> > there are any way to create an expression like these and correct?
> >
> > Thank you!!!
> >
> Now I have a correct expression (thanks to Chema Cortés from spanish 
> zope list). This is the expression:
> 
> (len(dictionary['value1'])>6 and dictionary['value1'][5]) or 'Value not available'

Just for the records:

(dictionary.get('value',[])[5:]+['Value not available'])[0] 

is the functional programming approach to this problem.

Regards
Tino



More information about the Zope mailing list