error with tal:condition="python:x in s"
Greetings. I was wondering if this is a bug, or if I'm just doing something wrong. I'm trying the following page template code: <span tal:condition="python:'string' in s"> </span> s is a list of strings. I'm trying to condition on membership of 'string' in the list s, but I get the following error: exceptions.TypeError on 'in ' requires character as left operand in "", at line 56, column 4 any help would be appreciated. regards, Christian Gromoll
It seems as though s is not treated as a list of strings, rather as a single string. 'In' would thus look for a character, since a string is a list of characters. Hedley -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of H. Christian Gromoll Sent: 17 September 2002 12:34 To: zope@zope.org Subject: [Zope] error with tal:condition="python:x in s" Greetings. I was wondering if this is a bug, or if I'm just doing something wrong. I'm trying the following page template code: <span tal:condition="python:'string' in s"> </span> s is a list of strings. I'm trying to condition on membership of 'string' in the list s, but I get the following error: exceptions.TypeError on 'in ' requires character as left operand in "", at line 56, column 4 any help would be appreciated. regards, Christian Gromoll _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Tue, Sep 17, 2002 at 12:47:35PM +0200, Hedley Roos wrote:
It seems as though s is not treated as a list of strings, rather as a single string. 'In' would thus look for a character, since a string is a list of characters.
That's my bet too. FOr this kind of traceback, it's often helpful to "View Source" in your browser: it was robably something like: TypeError: 'in <string>' requires character as left operand Angle brackets are used by python to show the type of objects in tracebacks like this, but your browser helpfully thinks it's a tag and hides it from you. The <string> would have been a clue... --PW -- Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
participants (3)
-
H. Christian Gromoll -
Hedley Roos -
Paul Winkler