--include-builtins fails #20

fdev31 opened this Issue Dec 3, 2011 · 12 comments


None yet

3 participants


There is a typo in pyjs.py file:

                builtins = open(os.path.join(os.path.dirname(__file__)), "py-builtins.js").read()

should be

                builtins = open(os.path.join(os.path.dirname(__file__), "py-builtins.js")).read()

Thank you very much for reporting this! As it happens, I am no longer associated with qsnake/py2js since we had a difference of opinion in which way to take the project. Therefore I maintain a fresh branch over at https://github.com/chrivers/pyjaco, where many new features are implemented and this bug is fixed.

However, I would like to point out that I am NOT the primary author of qsnake/py2js, but I am one of the lead devs on pyjaco. I wish py2js all the best. I merely want you to know that alternatives exist :-)


Could you give some examples of the problems you have had? I'd like to make sure they are fixed :)

Also, keep in mind that by now, py2js and pyjaco are totally different projects. Things might work better in one or the other, as they have different goals.

@certik certik added a commit that closed this issue Dec 5, 2011
@certik certik Fix a typo (closes #20) 5e49eb8
@certik certik closed this in 5e49eb8 Dec 5, 2011
Qsnake member

Hi @fdev31, thanks a lot for reporting the bug! I've just fixed it. Let us know if you find more bugs, feel free to also send us pull requests.

@chrivers, good luck with your new project. I would suggest you to delete and repush your repository, so that github doesn't show that it is forked from py2js, so that people are not confused which project is which.


Thanks for the reactivity!
If I want to understand the main differences between py2js & pyjaco, where should I look ?


Thank you for your interest. Broadly speaking, the projects are very different by now, but I know that pyjaco is more centered on providing a real Python experience with pythonic types, classes and libraries.

Whereas py2js is more a tool to compile the syntax of python into syntactical javascript, pyjaco tries to translate the semantic meaning, which is a somewhat harder task. It (pyjaco) also has a javascript mode to provide syntactic translation, and a multiplexer to switch between the two with a very fine granularity. You can even tell it that certain vars are javascript vars, and then access to those vars will happen in javascript syntax.

You can learn more at our homepage: http://www.pyjaco.org/

And you are very welcome to join our google group (info on the homepage), and/or email me if you have questions.

The main github source repository is:


I think we should keep further discussion of pyjaco away from py2js. It wouldn't be fair to Ondrej if I just invaded his repository comments with mentions of my own project :-)

Qsnake member

Thanks for your words about pyjaco. Let my clarify the goals of py2js (you were not exactly precise above).

The goal of py2js is to provide a Python like experience in JavaScript by emulating Python types in a javascript library and translating the Python code using AST. The goal is that it should feel like Python. In addition to that, we want to allow fine granularity to be able to call raw JS libraries from within in.

I don't want to interpret the goals of pyjaco, but from what you wrote I think your goals are the same as ours. So I would say that the main difference is that pyjaco is developed mainly by @chrivers, while py2js by @certik. We were not able to work together on one project, so that's why there are two projects with almost the same goals.


Ondrej, apologies if I misunderstood the goals of py2js. I did not intend to misrepresent it.

I would love to work with you on py2js/pyjaco, if you are interested? In that case I think we should set up a pyjaco group on github to host the repository, so it can be shared by all involved.

I say "pyjaco" only because pyjaco is hundreds of commits ahead of py2js. It would be a common project, of course. What do you think?


Hey guys, sorry for not having answered to the question about the problems I encountered, in fact I only played a full afternoon but then I switched to "do nothing" (keep play javascript) for now and I can't remember precisely enough.
I can tell it was about "str" type, passed as argument to some jQuery functions required a String() cast :(
Some syntax is now allowed like the "$" sugar, but I suppose it's not an important issue.
try/except not being support sounded rude to me also :P
For lambdas & co, I think that was acceptable, but with some possible improvements I can't remember anyway.

About the fight of egos, that's so "classic" , I just can tell trying to work together is always more difficult.
At the end, people trying to conciliate may achieve a wonderful project, but those fighting alone rarely survive to the lack of energy and just do toys.
It's quite known that having divergent opinions it pretty god for the target : the final quality raises automatically
Sorry if I sound direct since we don't known each-other but try once more to work on a "merged" project if you think that is possible. If it's just marketing or implementation issues, then it's easy to make things better instead of different.


And be positive: you have a chance to get a real contributor to your project ! ;P


fdev31, thankk you for your comment.

In fact, I'm using pyjaco for a jQuery project right now, so it is possible :)

Of course, $ is not valid in python, so I've simply injected the raw javascript string "var Q = $" into the beginning of the translated code.

So instead of using


I can just use


which is valid python. When you pass a pythonic value to javascript, you have to convert it to a native javascript type with js(). So it would be something like this:

Q(js("#foo div.bar:first-child")).....

This works, I use it myself. Oh, and try-except is most definitely supported, in both projects I believe :)

I think we would both love the idea of having you contribute to "a / the / our" project, and I certainly would never exclude anyone. Because github as a standard course of action asks people to fork projects, it just sort of happened. I started contributing to py2js, but we wanted our forks to go in different directions.

Ondrej, what do you think?


Heh, I was talking as both of you as "contributors" of each-other ;)
I understood about the "$" limitation, that sounded "obvious" but still a theoretic bug since it can mask some js behavior.
Btw, from what I remember, I didn't try the js() function, that may explain some of my difficulties ;)
Forking of course is an option, with regular merge, but since, the differences only sounded "technical" but I suppose big part of the code base could be at least shared.
Having a library ? A tool set ? But definitely, having something in common sounds "simple".
If you both have strong vision on a project, trying to collaborate can give birth to something even stronger, don't you think ?
About the current goals, sorry If I understand badly, can I summarize to:

  • pyjaco tries to put the power on the python side, with generated "self-contained" javascript
  • py2js offers some kind of "python emulation layer" on the javascript side, some like of "python wrapper for javascript" but today both projects are hybrid... can you fix my vision ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment