TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Python-to-JavaScript Transpiler with BabelJS and SourceMaps

114 pointsby azazel75about 9 years ago

19 comments

mrharrisonabout 9 years ago
Can all of you python to javascript library creators get together and create one solid library, or maybe not all of you, because it would be a grid-lock of decisions. How about half of you with the most similar ideas get together and do one super solid library, instead of having 20 of these python to javascript libraries so the community can easily decide on one to use as a standard. This would be awesome! Thanks!
评论 #11398651 未加载
评论 #11398294 未加载
评论 #11397621 未加载
评论 #11397910 未加载
dangambleabout 9 years ago
When i ran this on the Django github to create DjangoJS it didn't work, any ideas?
评论 #11397785 未加载
评论 #11402429 未加载
fuhrysteveabout 9 years ago
I&#x27;m a little horrified to suggest this seriously, but this could be a cool way to accomplish consistent field validation between server and client.<p>I wrote this little library <a href="https:&#x2F;&#x2F;github.com&#x2F;fuhrysteve&#x2F;marshmallow-jsonschema#complete-example-flask-application-using-brutisinjson-forms" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fuhrysteve&#x2F;marshmallow-jsonschema#complet...</a> to convert marshmallow schemas to a JSON representation with the intention of passing it to a browser or mobile device for rendering. Imagine if you could also pass native code to be used by the client for validation. In other words: write your validator in python and use it server side - but <i>also</i> convert it to javascript so that the client can attempt to validate it before bothering to send a web request.
评论 #11396608 未加载
评论 #11399427 未加载
oksoabout 9 years ago
Looks interesting, but it has naming incoherences: &#x27;pip install javascripython&#x27; actually installs in site-packages&#x2F;metapensiero&#x2F;pj. I don&#x27;t get why it does not simply install in site-packages&#x2F;javascripthon.
wusterabout 9 years ago
If you want to build the web with Python, IMO the emphasis should be bringing Python to the web. I think a more promising project is <a href="http:&#x2F;&#x2F;pypyjs.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;pypyjs.org&#x2F;</a> - a Python runtime in your browser powered by asm.js<p>Listen to this podcast where the author describes the project: <a href="https:&#x2F;&#x2F;talkpython.fm&#x2F;episodes&#x2F;show&#x2F;32&#x2F;pypy.js-pypy-python-in-your-browser" rel="nofollow">https:&#x2F;&#x2F;talkpython.fm&#x2F;episodes&#x2F;show&#x2F;32&#x2F;pypy.js-pypy-python-i...</a>
评论 #11399539 未加载
orfabout 9 years ago
This is awesome! One comment, it might be a good idea to make the docstrings in JS appear above the functions rather than inside them? Chrome refuses to optimize functions if they are above a certain size in bytes, which includes comments, so it seems most &#x27;docstrings&#x27; are placed above the definition rather than inside. Also does str(x) convert to x.toString(x)?<p>I&#x27;m going to use this in a project I have in mind :)
评论 #11397540 未加载
maaaatsabout 9 years ago
So this transpiler makes ES6 code and then Babel makes it runnable on most browsers, or does it leverage Babel in making JS code in the first place?
评论 #11396371 未加载
评论 #11396329 未加载
dkopiabout 9 years ago
For-in array can be implemented using ES6&#x27;s for-of. <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Reference&#x2F;Statements&#x2F;for...of" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en&#x2F;docs&#x2F;Web&#x2F;JavaScript&#x2F;Referen...</a><p>Also, Not sure if it would be correct to implement a python dict using an ES6 map. If the keys are all strings, probably better to stick to a JS object. Check out the performance difference: <a href="http:&#x2F;&#x2F;jsperf.com&#x2F;es6-map-vs-object-properties&#x2F;73" rel="nofollow">http:&#x2F;&#x2F;jsperf.com&#x2F;es6-map-vs-object-properties&#x2F;73</a>
评论 #11396655 未加载
tlrobinsonabout 9 years ago
Python and modern JavaScript seem like fairly similar languages (dynamically typed, object oriented&#x2F;functional hybrid, rich ecosystem of packages), the biggest difference being Python&#x27;s &quot;batteries included&quot; standard library, which presumably isn&#x27;t (all?) available in the browser.<p>So is the main reason to use this just familiarity with Python, minimal context switching if your backend is in Python, and the potential for a bit of code reuse between front&#x2F;backend?
评论 #11397522 未加载
bildungabout 9 years ago
How does interfacing with existing JS libraries work? I try to imagine how using this with a bootstrap theme (=jQuery) would look like.
评论 #11396628 未加载
ameliusabout 9 years ago
Related: <a href="https:&#x2F;&#x2F;blog.glyphobet.net&#x2F;essay&#x2F;2557" rel="nofollow">https:&#x2F;&#x2F;blog.glyphobet.net&#x2F;essay&#x2F;2557</a><p>By the way, I prefer Javascript&#x27;s scoping rules over Python&#x27;s. Also, it is easier to create a lexical block in Javascript than in Python.
评论 #11397389 未加载
评论 #11396883 未加载
anaphorabout 9 years ago
<a href="https:&#x2F;&#x2F;twitter.com&#x2F;pmrondon&#x2F;status&#x2F;648251230804946944" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;pmrondon&#x2F;status&#x2F;648251230804946944</a>
amiroucheabout 9 years ago
It&#x27;s Python with javascript ES6 semantic, there is no support for Python list, dict or support for Python magic parameters <i></i>kwargs. Good work nonetheless.
评论 #11396548 未加载
enitihasabout 9 years ago
Related: <a href="https:&#x2F;&#x2F;github.com&#x2F;atsepkov&#x2F;RapydScript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;atsepkov&#x2F;RapydScript</a>
评论 #11397183 未加载
crudbugabout 9 years ago
Does this support:<p>1. CommonJS modules<p>2. Static types<p>3. Webpack loader<p>Having CommonJS module support will enable polyglot development where language syntax live inside a module and everything follows JavaScript semantics.
评论 #11397238 未加载
irascibleabout 9 years ago
Either make python a first class web lanGuage (not gonna happen) or just write in javascript. It&#x27;s awesome.
techdragonabout 9 years ago
It&#x27;s an awesome library&#x2F;tool yay for more Python to JS tools!
forgotusername2about 9 years ago
have you heard about coffee??? ((:
评论 #11397109 未加载
评论 #11397668 未加载
diskcatabout 9 years ago
Does this actually mean I can now write python code instead of JS for websites?
评论 #11396392 未加载