Welcome to Transcrypt's documentation!¶
Can't find what you're looking for? The on-line version of this documentation is frequently updated, reflecting the newest features and troubleshooting procedures.
Table of Contents:¶
- 1. Transcrypt: what and why
- 2. Getting started
- 3. Special facilities
- 3.1. Transcrypt's module mechanism
- 3.2. Using browser stubs to test non-GUI code that uses console.log and window.alert
- 3.3. Creating JavaScript objects with __new__ (<constructor call>)
- 3.4. Identifier aliasing: __pragma__ ('alias', ...) and __pragma__ ('noalias', ...)
- 3.5. Generating __doc__ attributes from docstrings: __pragma__ ('docat') and __pragma__ ('nodocat')
- 3.6. Surpassing the speed of native JavaScript: __pragma__ ('fcall') and __pragma ('nofcall')
- 3.7. Automatic conversion to iterable: __pragma__ ('iconv') and __pragma__ ('noiconv')
- 3.8. Conditional compilation: __pragma__ ('ifdef', <symbol>), __pragma__ ('ifndef', <symbol>), __pragma__ ('else') and __pragma__ ('endif')
- 3.9. Inserting literal JavaScript: __pragma__ ('js', ...) and __include__ (...)
- 3.10. Create bare JavaScript objects and iterate over their attributes from Python: __pragma__ ('jsiter') and __pragma__ ('nojsiter')
- 3.11. Keeping your code lean: __pragma__ ('jskeys') and __pragma__ ('nojskeys')
- 3.12. Keeping your code lean: __pragma__ ('jsmod') and __pragma__ ('nojsmod')
- 3.13. Keeping your code lean: __pragma__ ('kwargs') and __pragma__ ('nokwargs')
- 3.14. Preventing target annotation: __pragma__ ('noanno')
- 3.15. Operator overloading: __pragma__ ('opov') and __pragma__ ('noopov')
- 3.16. Skipping fragments while generating code : __pragma__ ('skip') and __pragma__ ('noskip')
- 3.17. Automatic conversion to truth value: __pragma__ ('tconv') and __pragma__ ('notconv')
- 4. The philosophy behind Transcrypt and its impact on design decisions
- 5. The main differences with CPython
- 5.1. Differences due to the compiled, rather than interpreted nature of Transcrypt.
- 5.2. Differences due to the 'lean and mean' design goal.
- 5.3. Differences due to interoperability with JavaScript and JavaScript libraries.
- 5.4. Differences due to running Transcryp applications in the browser, rather than on the desktop.
- 6. Systematic code examples: a guided tour of Transcrypt
- 6.1. Arguments: **kwargs, *args, defaults, at call and def time, also for lambda's
- 6.2. Attribute access by name: getattr, setattr, hasattr
- 6.3. Classes: multiple inheritance and assignment of bound functions
- 6.4. Complex numbers: Python's builtin complex datatype
- 6.5. Conditional expressions: simple and nested
- 6.6. Control structures: for...else, while...else, if...elif...else, break, continue
- 6.7. Data structures: tuple, list, dict, set
- 6.8. Decorators: function and class, with and without parameters
- 6.9. Dict comprehensions
- 6.10. Diverse fixes
- 6.11. Diverse pulls
- 6.12. Dictionaries: dict revisited
- 6.13. Docstrings: __doc__ attribute generated optionally
- 6.14. Exceptions: exception class hierarchy, finally
- 6.15. Extended slices: facilitating NumScrypt and such
- 6.16. General functions: sort and sorted
- 6.17. Indices and slices: LHS, RHS, basic and extended
- 6.18. Iterators and generators
- 6.19. Lambda functions with all types of args
- 6.20. List comprehensions: multi-loop and nested with multiple if's
- 6.21. Local classes: inside other classes and functions
- 6.22. Metaclasses: overriding type.__new__ in a descendant metaclass
- 6.23. Module builtin: a small part of it demo'ed
- 6.24. Module cmath: allmost all of Python's cmath module
- 6.25. Module itertools: allmost all of Python's itertools module
- 6.26. Module math: allmost all of Python's math module
- 6.27. Module random: most important functions of Python's random module
- 6.28. Modules: hierarchical, both local to the project and global url-based
- 6.29. Nonlocals
- 6.30. Operator overloading
- 6.31. Properties
- 6.32. Set comprehensions
- 6.33. Simple and augmented assignment
- 6.34. Truthyness: optional Python-style evaluation of truthyness, falsyness and non-empty container selection
- 6.35. Tuple assignment: recursive and in for-headers using enumerate
- 7. Seamless interoperation with the DOM
- 8. Mixed examples
- 8.1. Three ways of integration with JavaScript libraries
- 8.2. Example: Pong
- 8.3. Joined minification
- 8.4. Example: jQuery
- 8.5. Example: iOS web app with native look and feel
- 8.6. Example: D3.js
- 8.7. Example: React
- 8.8. Example: Riot
- 8.9. Example: Using input and print in a DOM __terminal__ element in your browser
- 9. Autotesting Transcrypt code