Questions tagged [transcrypt]
This tag is reserved for any questions involving the Transcrypt Python to JavaScript compiler.
88
questions
0
votes
1
answer
42
views
Stuck migrating Pinescript v2 to v4
Noob learning here!
after a couple of days trying to convert a pinescript V2 to V4 from a extended script..
I cannot make a clean migration for the next part of the while script.
When save and it’s ...
1
vote
1
answer
94
views
Can Transcrypt produce React class components?
I've tried to convert the Transcrypt react example to use a class component. Full code at the end but the main change is to convert this function component:
def ListItems(props):
items = props['...
0
votes
0
answers
46
views
Downgrade Transcrypt version
I'm using transcrypt for encryption of sensitive files in my project.Right now i'm using version 2.2.0 but I want to downgrade it to version 2.1.0. I tried uninstall it in my project and reinstall ...
1
vote
1
answer
54
views
Transcrypt not converting strip() function
So, I have this python file that generates a list of numbers and converts them into a string:
def gen():
array = []
for value in range(10):
array.append(value)
random.seed(20)
...
0
votes
1
answer
47
views
Transcrypt and SVG creation here: defs
I want to create the following SVG programmatically. I have found an svg which I want to translate to transpile it into javascript code.
<svg xmlns="http://www.w3.org/2000/svg" viewBox=&...
0
votes
1
answer
31
views
Transcrypt and SVG creation
Hi I have managed to create a SVG with Python via Transcrypt. The code is like this:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class SVG:
def __init__(self):
self.svg = document....
0
votes
1
answer
90
views
Is there a way to have Transcrypt export all imported symbols in a module?
I have a medium-sized Python project that I'm trying to Transcrypt into ES6. One portion of the project is a lot of internals, and I've stashed it away in a "private" package (bezoar._model)....
0
votes
2
answers
47
views
How to make Transcrypt skip a line (without "try")?
The program I write should be able to run both directly via the interpreter and via Transcrypt. The problem is that I need to skip some lines when Transcrypt is running and "try" does not ...
0
votes
1
answer
86
views
Error message seems ambiguous without any descriptive clue
I am new to transcrypt. I created a test python file,test.py
def test_def(a: list):
for i in range(len(a)):
print(i)
xx = [2, 3, 4]
test_def(xx)
I have python 3.9. If I run the ...
2
votes
1
answer
181
views
Transcrypt without java?
I try out the "hello" example in the Transcrypt tutorial but get the following error message:
bash-4.3$ transcrypt hello
Transcrypt (TM) Python to JavaScript Small Sane ...
1
vote
2
answers
384
views
how to setup transcrypt
I am following the Get started part provided by transcrypt, created a folder named hello and then created the two files hello.py,hello.html
My goal is to run a function on the client side and output ...
0
votes
1
answer
68
views
Does Transcrypt support smtplib?
I need smtplib and other libs
is it possible to use Transcrypt for that purpose?
import os
import telebot
import smtplib
import textwrap
from email.mime.text import MIMEText
from email.mime.multipart ...
1
vote
1
answer
498
views
Transcrypt with import statement
I have a Python file called hello.py which is:
import openpyxl
def operate_excel():
file = 'dummy.xlsx'
new_row = ['data1', 'data2', 'data3', 'data4']
wb = openpyxl.load_workbook(...
0
votes
2
answers
173
views
HTML with Transcrypt script gives missing { before try block error
I am trying to add a javascript file that generated via Transcrypt from Python file.
However, when I add that script to my HTML file, there are some errors appeared in Console and I failed.
The Python ...
0
votes
3
answers
182
views
Write() function of the Turtle graphics library doesn't work with Transcrypt
When I use the write() function of the Turtle graphics library in a Python script and then translate it in javascript with Transcrypt, it displays nothing.
My code looks like this:
import turtle
def ...
0
votes
1
answer
354
views
Transcrypt is a compiler that translates Python into JavaScript ahead-of-time and dont working with sqlite3?
I try to execute command python -m transcrypt -b -m -n mr_index.py
and failed on code's string "import sqlite3". Why?
C:\Users\Legion\Downloads\meterrhyme-master>python -m transcrypt -b -...
0
votes
1
answer
80
views
Can you run Transcrypt and JavaScript at the same time?
I need to create a program that is able to do things possible in python only (I.E. Editing local files) while also using javascript API's
Would i be able to:
A. access variables defined in Transcrypt ...
4
votes
1
answer
482
views
Transcrypt gives can't import codecs error while importing json
I am trying to convert a python file to JS using transcrypt using the command transcrypt -b -m -n hello.py. I have an import to JSON in my python script:
import json
# the MAIN meaty function!!!
def ...
2
votes
1
answer
4k
views
How can I make JavaScript modules work in IE 11
I have JavaScript modules which I want to use with IE11.
In the HTML pages they are referenced like this:
<script type="module">
import * as mystuff from './scripts/mystuff.js'; ...
0
votes
2
answers
1k
views
How to import js modules in Python with Transcrypt
I have a very Python-ic script which compiles with Transcrypt, but the issue is that the one outside dependency I have is that I need to import google-cloud-bigquery. This obviously throws an error ...
1
vote
2
answers
958
views
Can't import sys or io
I'm attempting to import sys and io:
import sys
import io
but I get the following errors:
Error while compiling (offending file last):
File '/Users/username/worktest/index.py', line 11, at import ...
1
vote
1
answer
204
views
How can I read the contents of an URL with Transcrypt? Where is urlopen() located?
In Transcrypt I try to read JSON data from a URL, so I try:
import urllib.request
data = urllib.request.urlopen(data_url)
But I get the error "Import error, can't find [...] urllib.request&...
1
vote
1
answer
2k
views
parcel-plugin-transcrypt fails with 'Error: Cannot find module 'parcel-bundler/src/Logger'
In a web project using yarn as package manager and parcel as bundler, I want to let Parcel transpile Transcrypt (Python) files to Javascript.
For this I installed parcel-plugin-transcrypt. But now ...
1
vote
1
answer
909
views
How to use transcrypt in Python
I'm trying to transpile some simple examples, as the turtle tree example (https://github.com/bunkahle/Transcrypt-Examples/tree/master/turtle), using Pyhton 3.7.6 and transcrypt 3.7.16.
Basically, I'...
1
vote
1
answer
112
views
Using Transcrypt with Leaflet Maps
I love Python, and have never much cared for JavaScript. So I was pretty excited to learn about Transcrypt. I recently started a web-based project that uses Django for the back-end and a Leaflet map ...
1
vote
1
answer
108
views
Is transcrypt supposed to run from the local filesystem?
I've installed Transcrypt, compiled the Hello Solar System demo, and run it as instructed using the python web server.
However, I was also able to run the hello.html file directly from Chrome on ...
1
vote
1
answer
783
views
Transcrypt compilation error Python 3.7 Windows
I just tried the latest transcrypt on Python 3.7 Win7 with the simple program from https://github.com/bunkahle/Transcrypt-Examples/blob/master/alerts/alerts2.py but I got an compilation error:
C:\...
2
votes
1
answer
762
views
Both Python and React/Redux in browser? (WAS: Transcrypt and React/Redux)
I like python for quick prototypes of (sometimes) quite complex systems. On the other hand, I also like the "modern" web frameworks (react, angular) flexibility and rapid development for UI.So I'm ...
0
votes
2
answers
560
views
Python in browser with NLTK or alternative?
Is there a Python front-end that supports nltk?
I am building a custom application that needs to do stemming and stopping, and related processing, on a simple words query from inside the browser. ...
1
vote
1
answer
275
views
Why does Transcrypt compilation not work inside a Python script with the line: os.system('python -m transcrypt -b -m -n <somePythonFile>.py')?
I have a Python file translate2JS.py that I am trying to dynamically translate to JS after writing a Python function body to it. Here is the file CURRENTLY for the sake of illustrating the issue:
...
0
votes
1
answer
154
views
How to import a module with "-" in its name in transcrypt?
I'm writing my first transcrypt code (python transpiled to JS for the browser -- what a great idea!) and I'm stuck already, translating this JS code into python:
import { saveAs } from 'file-saver';
...
2
votes
2
answers
158
views
Transcrypt: How to check for empty list?
This a simple python program which causes an endless loop when compiled with Transcrypt 3.7.5:
stack = [ch for ch in "Hello"]
while stack:
print(stack.pop())
This can be solved by replacing ...
6
votes
1
answer
2k
views
Change in behaviour of dataclasses
I am working on release 3.7.1 of the Transcrypt Python to JavaScript compiler.
Part of the release procedure is a shipment test, in which Transcrypt is tested back to back with CPython.
It used to ...
0
votes
1
answer
183
views
When compiling python using transcrypt is it possible to get standard python error logging?
When compiling python to javascript using transcrypt I've noticed the syntax error reporting is more vague than the standard python syntax error reporting. Since the code cannot be compiled using the ...
2
votes
1
answer
2k
views
SKLearn Model in React-Native App
I'm trying to figure out the best way to use an sklearn model (ex: RandomForestClassifier, etc.) in a react-native app. I've been able to export the model using pickle, but I don't know the best way ...
0
votes
1
answer
297
views
How can one make Transcrypt compile to object rather than dict?
I'm trying to use the fetch API from Transcrypt.
Source:
headers = {
"Access-Control-Request-Method": "GET",
"Access-Control-Request-Headers": "origin, x-requested-with",
"Origin": "...
16
votes
1
answer
2k
views
Why don't Python 3.7 dataclasses support < > <= and >=, or do they?
For version 3.7.1 of the Transcrypt Python to JavaScript compiler I am currently using the new @dataclass decorator. I had expected that ==, !=, <, >, >=, <= would be supported, as per the ...
1
vote
1
answer
216
views
re finditer produces javascript with uncaught exception
I am trying to compile some simple Python code to Javascript using "transcrypt -e 6". When I use finditer from Python's re module, the resultant Javascript code has an uncaught exception during ...
1
vote
2
answers
435
views
Python - Can't import module 'PIL'
I have written code to compress image in .py file and tried to compile using transcrypt to convert to JS file. During this process i got the below error(screen shot) But if i run the .py file ...
0
votes
1
answer
641
views
ES6 named import introduces a const?
In implementing the Python module mechanism on top of ES6 modules for the Transcrypt Python to JavaScript compiler, I am faced with the following problem:
There are a large number of standard ...
1
vote
0
answers
276
views
Can't get modules to work in node.js
I am trying to run a program using ES 6 modules in node.js v9.10.1, using the --experimental-modules option. Note that the version not using ES 6 modules runs fine.
The module has been generated with ...
0
votes
1
answer
89
views
Can't get sourcemaps to work in Firefox
For the upcoming version of the Transcrypt Python to JS compiler, support for ES6 modules was added.
However I can't get sourcemaps to work in Firefox, while in Chrome they work flawlessly.
I am using ...
1
vote
1
answer
89
views
Transcrypt preprocessor
I'd like a piece of advice : I would like to setup a python dev environment so that I can a maximum of code in Python and then compile it with python or by using Transcrypt.
To add some more salt to ...
2
votes
0
answers
212
views
How can I list all exported names of a ES 6 module to implement Python's 'globals' function
To make the Transcrypt Python to JavaScript compiler suitable for the use of ES6 modules, I have to implement a.o. the Python globals function.
Currently during tranpilation all globals are ...
0
votes
1
answer
263
views
Can't get EXPORT AS DEFAULT to work on chrome Version 64.0.3282.186 (Official Build) (64-bit)
I am investigating adding ES6 import/export to the Transcrypt Python to JavaScript compiler.
As an experiment to that end I have the following code:
<!DOCTYPE html>
<html>
<head>...
1
vote
1
answer
321
views
Transcrypt and Javascript this with jQuery
I want to translate this sample html doc to Transcrypt:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></...
0
votes
2
answers
85
views
Transcrypt and TranscryptFrame
Right now I am working on a wrapper for common functions for transcrypt called TranscryptFrame. I get a compiler error and I like to know if we can solve this in any way, maybe it is just a little ...
1
vote
1
answer
192
views
transcrypt and magnifier code
I have tried to port a Javascript program for a magnifier via Transcrypt to Python code. Unfortunately I can not get rid of the frame of the magnifier which completely overrides the complete image. ...
3
votes
1
answer
813
views
Using XMLHttpRequest() in Transcrypt
I only have minimal JavaScript knowledge from coding a small API site entirely client-side.
How would I use XMLHttpRequest() in Transcrypt? Or should I be using URLlib or something else?
Is it as ...
3
votes
1
answer
199
views
Transcrypt and the .mod.js file
What is the sense of the mod.js file which transcrypt is generating when compiling javascript code from the Python code? I understand that it seems to hold the pure routine compiled to Javascript ...