Or you can use ASSIGNJS helper

{{=ASSIGNJS(js_array = python_list)}}

http://gauravvichare.com/how-to-assign-python-variable-to-javascript-variable-in-web2py/

On Tuesday, January 24, 2017 at 9:22:08 PM UTC+5:30, Anthony wrote:
>
> On Tuesday, January 24, 2017 at 7:43:24 AM UTC-5, Ramos wrote:
>>
>> try 
>> var lista = {{=*XML(*dic["signals_list"]*)*}};
>>
>
> To be safe, you might instead want to convert the Python object to JSON:
>
> var lista = {{=json.dumps(dic['signals_list'])}};
>
> The latter approach will always generate a valid Javascript object 
> (assuming the object is JSON serializable), whereas the former may not in 
> some circumstances. For example:
>
> XML(['a', 'b', None]) will yield:
>
> var lista = ['a', 'b', None]
>
> which is not valid Javascript.
>
> But json.dumps(['a', 'b', None]) will yield the correct:
>
> var lista = ["a", "b", null]
>
> The difference is that XML() ultimately just calls str() on the object, 
> whereas json.dumps generates a proper JSON object.
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to