Js2Py
Js2Py copied to clipboard
Extend console.log and js object str on py3
Another small PR but small PR's get merged quicker :)
This one prints all arguments passed to console.log and also makes __unicode__ work as expected in py3. repr still used __repr__ but str uses __str__ (or __unicode__ on py2) so when printing objects we get the expected result (strings without quotes).
Also now supports calling console.log with no arguments to print a blank line.
console.log('test:', 10);
console.log();
from js2py.pyjs import *
# setting scope
var = Scope( JS_BUILTINS )
set_global_object(var)
# Code follows:
var.registers([])
var.get(u'console').callprop(u'log', Js(u'test:'), Js(10.0))
var.get(u'console').callprop(u'log')
pass
Woops, I guess the print function wasn't being imported. With a single argument it is still the keyword with a single option wrapped in extra parentheses. I'll fix that. Glad you've got ci setup :)