Interesting idea! Of more immediate interest, to me at least, is the
underlying python-to-js translator (pycow 0.1) that emits very
readable and nicely indented Javascript. See
http://code.google.com/p/pygowave-server/wiki/PythonToJavaScriptTranslator
for the full scoop.
I installed pycow and ran a small python script that defines a
function and a class with nested lists and dictionaries as default
arguments. All in all not bad -- in fact very nice -- as a way to
understand the mapping between python and js syntax. I think I'll
definitely be using it for generating scripts that go in widgets and
views.
Here's what I put in:
-----------------------------------------
def hello(name):
print "Hello %s"%name
@Class
class Foo(object):
def __init__(self,myname='Mike',
mylist = ['x',3.14, [1,2]],
mydict={'a':1,'b':2, 'y':{'c':3,'d':4}}):
self.myname=myname
self.mylist=mylist
self.mydict=mydict
def myhello(self):
hello(self.myname)
myobj = Foo()
myobj.hello()
---------------------------------------
and here's what came out ...
-----------------------------------------
var hello = function (name) {
dbgprint("Hello %s" % name);
};
var Foo = new Class({
initialize: function (myname, mylist, mydict) {
if (!$defined(myname)) myname = "Mike";
if (!$defined(mylist)) mylist = ["x", 3.14, [1, 2]];
if (!$defined(mydict)) mydict = {
a: 1,
b: 2,
y: {
c: 3,
d: 4
}
};
this.myname = myname;
this.mylist = mylist;
this.mydict = mydict;
},
myhello: function () {
hello(this.myname);
}
});
var myobj = new Foo();
/* Warning: Cannot infer type of -> */ myobj.hello();
------------------------------------------
Now I can't swear that the output is correct as I haven't tested it
yet and there are plenty of limitations -- e.g.
* no support for import,
* no understanding of built-ins ie. {'a':1} is ok but not dict(a=1)
* doesn't grok list comprehensions
* and much more ...
Still I could see it growing into a very useful tool, esp if
development continues. I'd love to have a new helper class, say
PYJSCRIPT that could be used in views, e.g
{{=PYJSCRIPT("some python code")}}
that would emit
<script> some corresponding javascript </script>
Cheers,
Mike
On Jul 15, 8:10 am, mdipierro <[email protected]> wrote:
> I do not know myself. I am not sure how well it works.
>
> On 15 Lug, 06:23, weheh <[email protected]> wrote:
>
>
>
> > I have to digest this a little more to understand the implications.
> > What do you think of it, Massimo?.
>
> > On Jul 15, 4:14 am, mdipierro <[email protected]> wrote:
>
> > >http://www.skulpt.org/