On Thu, Apr 19, 2012 at 11:28 AM, satoshii <satoshi.cont...@gmail.com>wrote:

> Hello.
> Please see the code below:
>
>
>>     <table>
>>       $for r in xrange(31):
>>       <tr>
>>         $for c in xrange(31):
>>         <td>
>>           $if r == 0 and c == 0: $pass
>>           $elif r == 0: $goesc[c-1].name
>>           $elif c == 0: $goesr[r-1].gou
>>           $else:
>>             $if r == c:
>>               <input type="text" id="r$(r)c$(c)" name="r$(r)c$(c)"
>> class="text same" placeholder='$r->$c' value="$nicks['r1c1']" />
>>             $else:
>>               <input type="text" id="r$(r)c$(c)" name="r$(r)c$(c)"
>> class="text" placeholder='$r->$c' value="$nicks['r1c1']" />
>>         </td>
>>       </tr>
>>     </table>
>
>
> Look at the variable named "nicks".
> It's a dictionary those keys are from "r1c1" to "r30c30".
> I want to write like this, but it shows error.
>
> $nicks['r$(r)c$(c)']
>
>
You should use:

$nicks['r%dc%d' % (r, c)]

Python expression starts with a $. And after that it is Python, $
substitutions won't work and you have to use the Python rules there.

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com.
To unsubscribe from this group, send email to 
webpy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to