4 ms·
XMLHttpRequest is a facility provided by the browser - when you are making a request, you are just accessing objects and functions provided by the host environm
by shantanubala 13y ago
XMLHttpRequest is a facility provided by the browser - when you are making a request, you are just accessing objects and functions provided by the host environment.
In Python, the "host environment" is generally CPython with the standard library. In JavaScript, the "host environment" is typically the browser with the DOM.
This is a project that translates code in Python syntax to JavaScript, so you would use XMLHttpRequest just as you would in JavaScript, but with Python syntax.
- knappador 13y agoSo if I get the names perfect, I can use the js API's provided by the browser and only need to compile to test my code? Next. No...not next. Please no more next. Make it stop. Just stop. Please. There are so many projects that can use your assistance. I can give you ten open issues off the top of my head that I would like fixed. So many useful, interesting, thought-provoking programs are just dying to be written.
- bulatb 13y agoIf they haven't already, they could hide the DOM and nasty host-provided objects behind something more Pythonic. As long as it transpiles to XMLHttpRequests, it doesn't matter what the Python looks like.
- knappador 13y agoAnd I'll build a mock environment so that I can run my python script as if there is a real DOM to manipulate, and then I'll write a test rendering system to actually display the page as if everything is running in Python. Eventually I'll just implement every single aspect of a web browser so that I can be sure that after I stop transpilfering Python, I can indeed just start putting <script type="text/python"> everywhere and convince everyone to use it, so my giant mock environment will become the latest, greatest browser, and Google will spend millions adding a tune-able JIT to cpython, leading someone to decide what a great idea it would be to use this JIT as the runtime for server-side Python, and Pode.py will take over the web, and "isomorphic" Python frameworks will sprout faster than TCP connections on a DDOS'd server. And after that, we can start writing and re-writing everything to "transpile" to PHP and use hip-hop to make it C++. I can't spend any more attention on random me-to JS without feeling like I'm waiting for my vestigial appendix to fall out.
- amirouche 13y agoIn pythonium access to JavaScript objects is transparent look at the example app.py of the webgl demo: https://github.com/pythonium/pythonium.github.io/blob/master/js/app.py#L68 https://github.com/pythonium/pythonium.github.io/blob/master...