Earlier quoted context omitted.
In all my Python years, I have never needed to write a long anonymous function. I consider it a bit of a code smell. This isn't to say it's wrong to do in JS, just that the patterns in Python are different so you don't use this in practice.
I have never needed to write a long anonymous function. So two line of code is long now?
A Python 3 implementation for client-side web programming
91–100 of 120 posts
Re: A Python 3 implementation for client-side web programming
#92It's way nicer in my opinion, but I think its fussy white space is likely to be an issue for this use case. All the large Javascript libraries get minified etc, and Python really isn't open to that sort of stuff. It's a great language to use normally, but I don't see it replacing Javascript. I'd much rather write in Python and compile to Javascript though.
Re: A Python 3 implementation for client-side web programming
#93Earlier quoted context omitted.
> Someone has implemented Python in JavaScript. This isn't really true. This is far from a Python implementation. At best you could call it a Python-esque syntax to Javascript translator. And that's perhaps still useful. But to call this a Python implementation is quite simply a lie.
This is not a translator but an interpreter, there is no compilation. edit: except FUD, can you provide some points on which brython is failling, please ?
x = 1
def test():
print(x)
x = 2Re: A Python 3 implementation for client-side web programming
#94I do like the idea, but it inevitably suffers from the same flaw that afflicts all other compile-to-js libraries: making sense of errors will still require knowledge of how the underlying javascript works. Perhaps a development plugin for Chrome would allow debugging in python?
Every exception in brython has original line source, you don't need source maps. The thing is that you can't type Python in the console, yet.
Re: A Python 3 implementation for client-side web programming
#95Earlier quoted context omitted.
> Someone has implemented Python in JavaScript. This isn't really true. This is far from a Python implementation. At best you could call it a Python-esque syntax to Javascript translator. And that's perhaps still useful. But to call this a Python implementation is quite simply a lie.
This is not a translator but an interpreter, there is no compilation. edit: except FUD, can you provide some points on which brython is failling, please ?
def f():
n = 0
while n
This prints 0, 1, ... 10, 0 instead of just 0Re: A Python 3 implementation for client-side web programming
#96The way they position Brython is pretty off-putting and kind of confuses the issue. CoffeeScript page: "CoffeeScript is a little language that compiles into JavaScript." Brython page: "Brython is designed to replace Javascript as the scripting language for the Web." Maybe that's the end goal, but the reality is far from it. Of course JS is still required, and of course the Python gets compiled into JS. Finally, the a…
The approach and the phrasing seems exactly right to me and not at all off-putting. The goal of Brython is to replace javascript on the web, seems straightforward right? The way they go about it is to implement a compiler in javascript, and use that to bootstrap a python in the browser community. Seems like that is much easier than convincing Chrome/Firefox/IE to include a python compiler in their browser. How would…
Re: A Python 3 implementation for client-side web programming
#97Earlier quoted context omitted.
Noscript allows you to turn the Javascript off. Requiring javascript to see any content at all is a little absurd.
Javascript is a prerequisite of the modern web. Refusing to accept that is absurd.
Second, I whitelist sites for javascript. There's nothing absurd about that. Honestly, I can't believe people run any and all JS on every random page they land on.
Re: A Python 3 implementation for client-side web programming
#98Link to console demo from that page is broken, sadly. edit: looks like if you remove "_en" then you get to the right place, http://www.brython.info/tests/console.html Looks like pyjs, in that it has python syntax but JavaScript semantics, for example numbers turn into doubles here (but should be arbitrary-precision ints in Python).
Well, python 2.7: >>> a = 1/3 >>> type(a) int python 3.2 >>> a = 1/3 >>> type(a) brython: print(type(1/3))
x = 1
for i in range(100):
x = x*2
print(i, x)Re: A Python 3 implementation for client-side web programming
#99I love this. I wish someone would do this for Ruby. Not CoffeeScript - I want to be able to write Ruby that manipulates DOM objects.
Here's eight options for you. Enjoy: https://github.com/jashkenas/coffee-script/wiki/List-of-lang...
Re: A Python 3 implementation for client-side web programming
#100Earlier quoted context omitted.
Well, python 2.7: >>> a = 1/3 >>> type(a) int python 3.2 >>> a = 1/3 >>> type(a) brython: print(type(1/3))
Correct, that's a python 2/3 difference. But both 2 and 2 have arbitrary precision integers AFAIK, try this code x = 1 for i in range(100): x = x*2 print(i, x)
print(9**32-(9**32-5))
Also works (brython returns 0, python2&3 return 5)