ZPT: using variables to reference variables
hi, it's me again. how can i use a variable to name another variable before this variable gets expanded? e.g.: myvar = 14; a = 'myvar'; b = $($a); // b = 14 is this possible with ZPT and/or python? i am stuck... -- martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck keyserver problems? http://keyserver.kjsl.com/~jharris/keyserver.html get my key here: http://madduck.net/me/gpg/publickey stay the patient course. of little worth is your ire. the network is down.
martin f krafft wrote:
how can i use a variable to name another variable before this variable gets expanded? e.g.:
myvar = 14; a = 'myvar'; b = $($a); // b = 14
is this possible with ZPT and/or python?
It is possible with both. In a ZPT: <div tal:define="myvar python:14; a string:myvar; b python:path(a)"> In Python: myvar = 14 a = 'myvar' b = locals()[a] *However*, this will not work in Zope's Python-based Scripts, since they do not allow access to locals(). Cheers, Evan @ 4-am
Evan Simpson wrote:
It is possible with both. In a ZPT:
<div tal:define="myvar python:14; a string:myvar; b python:path(a)">
...or: <div tal:define="myvar python:14; a string:myvar; b ?a"> maybe? will-the-evil-but-cool-undocumented-syntax-work-here-ly yours, Chris
participants (3)
-
Chris Withers -
Evan Simpson -
martin f krafft