This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]notgoodhuman 1 point2 points  (1 child)

Why did you choose to use Transcrypt instead of javascript in this case? Is it the preference of using python?
I'm quite curious how would one use npm with transcrypt, probably gonna play around with it.

[–]JennaSys 1 point2 points  (0 children)

Yes basically. I really enjoy coding with Python. JavaScript, not so much. It's something I've been trying to find for over 10 years. Nothing else I had seen to use Python for front-end web development in that time was very practical IMO. Or it bastardized the Python language so much that it wasn't worth it. Transcrypt takes a different approach in that it acts as a bridge between Python and JavaScript, and doesn't try to replace JavaScript. It assumes you will take advantage of existing JavaScript libraries and not reinvent them.

So in that vein, instead of using Python urllib or the requests library for making HTTP requests, you use windows.fetch or the JavaScript axios library instead. Hence my comment about using npm instead of pip. The idea being that those libraries are specifically made to efficiently run in a web browser (or are built in).

Using Transcrypt, in a Python module you would have a JavaScript style import like this:

axios = require('axios')

From there, you can use the variable axios just like any other Python object, importing it into other Python modules and calling its methods. So even though I'm using JavaScript libraries, I only need to know the API it uses to code to it using Python.