Hermann Kaser wrote:
> On Sun, Jun 8, 2008 at 1:08 PM, kogu <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I am trying to learn web development in Python as well as Python. So
>> pardon the stupid questions for a few days. I promise, I will search
>> before posting here.
>>
>> Why isn't this code not working?
>>
>> $def with (input)
>> $for i in range(10):
>> Hello World!
>>
>> Error is
>>
>> <type 'exceptions.NameError'> at /dynamic/add
>> could not find 'range' (line 2)
>
> You need to add the function to the templates global scope like this:
>
> import template
> render = template.render('templates/')
> template.Template.globals['range'] = range
>
> Check out templator's documentation:
> http://webpy.org/templetor
You could even go as far as doing:
web.template.Template.globals['py'] = web.storify(__builtins__)
to call any python built-in function like this:
$def with (input)
$for i in py.range(10):
yow $i
cheers.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---