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.
edit: except FUD, can you provide some points on which brython is failling, please ?
x = 0
def impure():
global x
x += 1
return x
print(0 < impure() <= 1)
In python, impure() would only be evaluated once returning True, but Brython's chaining evaluates it twice, and so it returns False instead. Of course, this example isn't exactly something you'd usually see in actual code (heck, it's probably even bad practice in most situations) BUT the point here is that while most of python might be compatible with this, there exists some inconsistencies that causes one's previously working python code to fail (and these bugs would probably be very difficult to trace). Of course, Brython is still young and has time to hopefully fix these issues. (In fact, this is the second time I've tried this project. Back then they didn't even have the chaining feature working, so it's nice that they are making progress.)PyPy, jython, ironpython etc all had/have incompatibilities as the language evolves and as they work out the quirks in their respective runtimes.
This isn't compatible with cpython (afaik, none of the other runtimes have ever been COMPLETELY compatible, but this is much further off), but hell, it's pretty awesome.
As an aside, I'd shoot anyone who did that ^^ without a pretty amazing explaination.
It is a cool project, whichever one of these python in javasript things is to become successful needs to aim for the same level of compatibility as say Jython or IronPython - yes it would take a long time, but this sort of thing is needed to be a useful implementation.
x = 1
def test():
print(x)
x = 2 def f():
n = 0
while n < 10:
yield n
n += 1
print(n)
g = f()
print(next(g))
This prints 0, 1, ... 10, 0 instead of just 0> Brython is designed to replace Javascript as the scripting language for the Web
Yes, I know you can declare a function inside another and you get a closure. But, JavaScript's syntax is just nicer.
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.
So two line of code is long now?
I'm not sure if the developer is one person or if they wrote the landing page as well, but let's assume it is that same person.
If someone has focused enough energy to implement a language in JavaScript, it is probably fair say that marketing isn't his or her primary skill.
At the same time, reading over the text again, people have said crazier things and done much less. If the developer's goal is to replace JavaScript with Python and his or her first attempt is to implement Python in JavaScript, I, for one, applaud their effort.
and walked: "through the valley"' he's and feared: not: "evil"!
# he.and_walked("through the valley").and_feared(not("evil"))!
drop down:' criminal scum!
# criminal_scum.drop_down()!
eat: breakfast' you!
# you.eat(breakfast)!
kill: with pistol' maim: blunt object' opponent's check dead:
# opponent.maim(blunt_object).kill(with_pistol).check_dead()
print person's name's last
print person's last' name # ;)
# print person.name.last
if my's cookies's jar's empty::
print "Cookie Monster, why is the Cookie jar empty?"
why: cookie jar's empty:' cookie monster
# why cookie monster, why? :)
why: cookie jar's empty:' cookie monster's why: "?"
it's called Glas :)It would be amazing if browsers added interpreters natively, then we could check for a native interpreter and fall back to loading a JS one like brython.