Questions tagged [transcrypt]

This tag is reserved for any questions involving the Transcrypt Python to JavaScript compiler.

This tag is reserved for any questions involving the Transcrypt Python to JavaScript compiler.

Official website of Transcrypt: http://www.transcrypt.org

GitHub repository: https://github.com/qquick/Transcrypt

88 questions
74
votes
13 answers

How can I integrate Python and JavaScript?

Is it possible to integrate Python and JavaScript? For example, imagine you wanted to be able to define classes in JavaScript and use them from Python (or vice versa). If so, what's the best way? I'm interested not only if this is possible but if…
Jacob Gabrielson
  • 34,800
  • 15
  • 46
  • 64
15
votes
1 answer

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 PEP's abstract, but it doesn't seem to be the case: from…
Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
9
votes
1 answer

Performance if (typeof x == 'number')?

I've been Googling quite some time for e.g. 'typeof' and 'performance', but I haven't been able to find a satisfactory answer to the following problem. I am trying to implement complex numbers for the Transcrypt Python to JavaScript compiler, using…
Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
6
votes
1 answer

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 run flawlessly with the beta's of CPython 3.7, but…
Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
6
votes
1 answer

Python 3.6 AST module doesn't recognize async methods

In implementing coroutines in the Transcrypt Python to JavaScript compiler, I have the following weird problem. Transcrypt uses the native parser of CPython 3.6 to generate an AST. For async global function defs it generates an AsyncFunctionDef…
Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
4
votes
1 answer

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 exec_script_str(script_str, raw_input_lst_json,…
Sarwagya
  • 166
  • 11
4
votes
1 answer

Constructor new with transcrypt?

I would like to fetch a file via transcrypt code. Usually this is done with XMLHttpRequest. In Javascript scripts the new constructor is used for this. How do I proceed in transcrypt for it? Here is my not-working code: #!/usr/bin/env python # -*-…
bunkus
  • 975
  • 11
  • 19
4
votes
1 answer

How to use the python code in React Native app?

I want to use React Native as a front-end and the core logic to implement in python. How it can be implemented? Is there a python wrapper for js, with support for react native
3
votes
1 answer

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 simple as creating a new XMLHttpRequest object and…
Sam
  • 43
  • 4
3
votes
1 answer

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 which one has written in Python without any…
bunkus
  • 975
  • 11
  • 19
3
votes
1 answer

Transcrypt: using code from another python script causes 'TypeError: module is undefined'

I am having trouble splitting code across multiple files using transcrypt (version 3.6.95). As a basic example, I have the following files in the same directory: index.htm Transcrypt…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/transcrypt" class="post-tag grid--cell" title="show questions tagged 'transcrypt'" rel="tag">transcrypt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 21 '18 at 17:13">asked Feb 21 '18 at 17:13</time> <a href="../../users/5194459/dominic-price" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/5194459.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Dominic Price" /> </a> <div class="s-user-card--info"> <a href="../../users/5194459/dominic-price" class="s-user-card--link">Dominic Price</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,111</li> <li class="s-award-bling s-award-bling__silver" title="8 silver badges">8</li> <li class="s-award-bling s-award-bling__bronze" title="19 bronze badges">19</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-45464677"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/45464677/include-license-file-in-readme" class="question-hyperlink">Include license file in readme</a></h3> <div class="excerpt">I have a file README.rst that I use both for PyPi and GitHub. Since I want to include a license file also on GitHub, it contains the line: .. include:: transcrypt/license_reference.txt However this works neither on PyPi (whole file not parsed…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/github" class="post-tag grid--cell" title="show questions tagged 'github'" rel="tag">github</a> <a href="../../questions/tagged/pypi" class="post-tag grid--cell" title="show questions tagged 'pypi'" rel="tag">pypi</a> <a href="../../questions/tagged/transcrypt" class="post-tag grid--cell" title="show questions tagged 'transcrypt'" rel="tag">transcrypt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 02 '17 at 15:12">asked Aug 02 '17 at 15:12</time> <a href="../../users/1577341/jacques-de-hooge" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1577341.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Jacques de Hooge" /> </a> <div class="s-user-card--info"> <a href="../../users/1577341/jacques-de-hooge" class="s-user-card--link">Jacques de Hooge</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,750</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="28 silver badges">28</li> <li class="s-award-bling s-award-bling__bronze" title="45 bronze badges">45</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-44213824"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/44213824/transcrypt-inherit-from-a-js-prototype" class="question-hyperlink">Transcrypt: Inherit from a JS prototype?</a></h3> <div class="excerpt">Is there any way to inherit a Transcrypt class from a JS prototype? I've got a JS object type that has a fairly heavy set of functionality I need to preserve, but I'd like to extend it with a lot of the nice affordances in a Transcrypt class (in…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/transcrypt" class="post-tag grid--cell" title="show questions tagged 'transcrypt'" rel="tag">transcrypt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked May 27 '17 at 06:40">asked May 27 '17 at 06:40</time> <a href="../../users/1936075/theodox" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1936075.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="theodox" /> </a> <div class="s-user-card--info"> <a href="../../users/1936075/theodox" class="s-user-card--link">theodox</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">12,028</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="23 silver badges">23</li> <li class="s-award-bling s-award-bling__bronze" title="36 bronze badges">36</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-44054776"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/44054776/iterable-emulation-in-transcrypt" class="question-hyperlink">Iterable emulation in transcrypt</a></h3> <div class="excerpt">I've been trying to port a vector math library to transcrypt and I've bumped into an issue with emulating iterable types. I've got a Vector class with an inner iterable. Here's a simplified version of the core: class Vector: def __init__(self,…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/python-3.x" class="post-tag grid--cell" title="show questions tagged 'python-3.x'" rel="tag">python-3.x</a> <a href="../../questions/tagged/transcrypt" class="post-tag grid--cell" title="show questions tagged 'transcrypt'" rel="tag">transcrypt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked May 18 '17 at 17:52">asked May 18 '17 at 17:52</time> <a href="../../users/1936075/theodox" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1936075.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="theodox" /> </a> <div class="s-user-card--info"> <a href="../../users/1936075/theodox" class="s-user-card--link">theodox</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">12,028</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="23 silver badges">23</li> <li class="s-award-bling s-award-bling__bronze" title="36 bronze badges">36</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-43680819"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/43680819/transcrypt-cast-a-client-side-js-object-as-a-dict" class="question-hyperlink">Transcrypt: Cast a client-side JS Object as a dict?</a></h3> <div class="excerpt">I have a class definition that begins as shown below. class Ace11(): def __init__(self, register_list): """ Parse and validate the list of dicts. """ self.required_keys = """ briefdescription…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/transcrypt" class="post-tag grid--cell" title="show questions tagged 'transcrypt'" rel="tag">transcrypt</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 28 '17 at 12:57">asked Apr 28 '17 at 12:57</time> <a href="../../users/426853/mike-ellis" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/426853.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Mike Ellis" /> </a> <div class="s-user-card--info"> <a href="../../users/426853/mike-ellis" class="s-user-card--link">Mike Ellis</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,120</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="12 silver badge">12</li> <li class="s-award-bling s-award-bling__bronze" title="27 bronze badge">27</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=3" rel="" title="Go to page 3">3</a> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=4" rel="" title="Go to page 4">4</a> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=5" rel="" title="Go to page 5">5</a> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=6" rel="" title="Go to page 6">6</a> <a class="s-pagination--item" href="../../questions/tagged/transcrypt_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>