>
> From your code I assume your table data looks something like that:
>
> myTable = ((str, float), [('foo', 1.5), ('bar', 4242.42)])
>
> You can then do the following (assuming Py 2.5):
>
> <tr py:for="row in myTable[1]">
> <td py:for="d, t in zip(row, myTable[0])"
>    py:content="locale.format('%d', d, True) if t is float else d"
>    align="${'right' if t is float else 'left'}"/>
> </tr>
>
> To make it clearer and more scalable, you can also define functions
> format_data(data, data_type) and alignment(data_type) and use these:
>
> <tr py:for="row in myTable[1]">
> <td py:for="data, data_type in zip(row, myTable[0])"
>    py:content="format_data(data, data_type)"
>    align="${alignment(type)}"/>
> </tr>
>
> Hope that helps.


Thanks for prompt reply.
Trying to add following rows in my kid template
<?python
def formatData(dataType,cellContent):
    if dataType == float:
        pass
?>
throws this error:
.......

  File "/usr/lib/python2.5/site-packages/kid-0.9.6-py2.5.egg/kid/compiler.py",
line 114, in code
    self._code = py_compile(self.python, pyfile)
  File "/usr/lib/python2.5/site-packages/kid-0.9.6-py2.5.egg/kid/compiler.py",
line 46, in py_compile
    return _py_compile(code, filename, 'exec')
SyntaxError: unqualified exec is not allowed in function '_pull' it
contains a nested function with free variables (prodej.py, line 27)
Error in code generated from template file
'/kiss/software/TurboGears/fantomas/fantomas/templates/prodej.kid'
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
kid-template-discuss mailing list
kid-template-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kid-template-discuss

Reply via email to