You can edit almost every page by Creating an account and confirming your email.

Pytml: Difference between revisions

From EverybodyWiki Bios & Wiki
WikiMasterBot2 (talk | contribs)
Moved page from wikipedia
 
WikiMasterBot2 (talk | contribs)
m Moved page from wikipedia
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{AFC submission|d|nn|u=Aswanthr82|ns=118|decliner=Lynch44|declinets=20260622141647|ts=20260622135933}} <!-- Do not remove this line! -->
{{AfC submission|d|nn|u=Aswanthr82|ns=118|decliner=Sulfurboy|declinets=20261122161236|ts=20261122154622}} <!-- Do not remove this line! -->
{{AfC submission|d|nn|u=Aswanthr82|ns=118|decliner=Lynch44|declinets=20260622141647|small=yes|ts=20260622135933}} <!-- Do not remove this line! -->
 
{{Short description|JavaScript library for running Python code in web pages}}
{{Draft topics|internet-culture|software|computing|technology}}
{{AfC topic|other}}


<!-- Important, do not remove anything above this line before article has been created. -->
<!-- Important, do not remove anything above this line before article has been created. -->


'''Pytml''' is a JavaScript library that allows developers to embed and execute [[Python (programming language)|Python]] code directly within [[HTML]] pages. It leverages [[Pyodide]], a full Python interpreter compiled to [[WebAssembly]], to run Python code locally in the user's browser without requiring a backend server.
{{Infobox software
| name                  = Pytml
| developer              = Aswanth R
| released              = {{Start date and age|2026|6}}
| latest release version = 2.5.1
| latest release date    = {{Start date and age|2026|10|19}}
| programming language  = [[JavaScript]]
| genre                  = [[Library (computing)|Software library]]
| license                = [[Apache License|Apache-2.0]]
| website                = {{URL|https://pytml.js.org}}
}}
 
'''Pytml''' is an open-source [[JavaScript]] library that runs [[Python (programming language)|Python]] code written inside [[HTML]] pages. It uses Pyodide, a port of Python to [[WebAssembly]], so the code executes in the visitor's browser and no Python server is needed.<ref name="blog">{{cite web |last=R |first=Aswanth |date=19 October 2026 |title=Pytml: Python in Your HTML with a Single Script Tag |url=https://blog.pyodide.org/posts/pytml/ |website=Pyodide blog |access-date=22 November 2026}}</ref> It is developed by Aswanth R and released under the Apache License 2.0.<ref name="repo">{{cite web |title=NodeX-AR/Pytml |url=https://github.com/NodeX-AR/Pytml |website=GitHub |access-date=22 November 2026}}</ref>
 
The library was written with teaching in mind. Its developer has said the aim was to let people who already know some Python make a web page interactive without first learning JavaScript and the browser's [[Document Object Model]] (DOM) interfaces.<ref name="blog" /> It overlaps in purpose with [[PyScript]], and the project's own documentation describes it as a lightweight alternative to that framework.<ref name="repo" />
 
== Design ==
 
=== Syntax ===
A page loads Pytml with one <code>&lt;script&gt;</code> tag. Python code is then placed between <code>&lt;py&gt;</code> tags, in a <code>script</code> element of type <code>text/python</code>, or in an external file named by a <code>src</code> attribute.<ref name="repo" /><ref name="blog" /> When the page loads, Pytml starts Pyodide, finds these blocks and runs them.<ref name="lockergnome">{{cite web |last=Pirillo |first=Chris |date=18 November 2026 |title=Pytml runs Python inside HTML tags by loading a browser-side interpreter |url=https://lockergnome.com/run-python-inside-html-tags-in-browser-no-server/ |website=LockerGnome |access-date=22 November 2026}}</ref>
 
Tags written as <code>&lt;py1&gt;</code>, <code>&lt;py2&gt;</code> and so on mark separate programs. The number is an identifier and not a file name: blocks that share a number share one namespace, and blocks with different numbers do not.<ref name="repo" /> Version 2.5 also recognises numbered interface tags (<code>&lt;btnN&gt;</code>, <code>&lt;inputN&gt;</code> and <code>&lt;txtN&gt;</code>) inside a Python block. Before the code reaches Python, a preprocessing step removes these tags from the source, leaves the surrounding text and its indentation unchanged, and inserts the matching button or text field into the page.<ref name="blog" />
 
=== Page elements and events ===
Elements that have an <code>id</code> attribute are made available to Python as variables with the same name. Each variable is a thin wrapper around the browser's own DOM object, with properties such as <code>text</code> and <code>value</code>.<ref name="blog" /> Event handlers are attached with an <code>on()</code> method, which passes the browser event to a Python function as a dictionary-like object and returns a function that removes the handler again.<ref name="blog" /> Because this design relies on direct access to the page's DOM, it runs on the browser's main thread and not in a web worker.<ref name="blog" />


The library is designed to be a minimal, zero-boilerplate solution for running Python in the browser. It automatically initializes Pyodide when the page loads, captures Python's `print()` and `input()` functions, and displays their output as HTML elements. This allows developers to use standard Python syntax inside HTML tags such as `<py>print("Hello World")</py>`.
=== Input and output ===
Text sent to <code>print()</code> is shown on the page, and uncaught exceptions are reported there as well.<ref name="lockergnome" /> Python's <code>input()</code> normally pauses a program until the user types something, which a browser cannot do without freezing the page. Pytml therefore rewrites such calls using Python's abstract syntax tree tools so that they wait asynchronously for a text field on the page.<ref name="blog" />


== History ==
=== Packages and browser features ===
Packages are installed through Pyodide's <code>micropip</code> tool. Packages that Pyodide already provides, including [[NumPy]], [[pandas (software)|pandas]] and [[Matplotlib]], can be used.<ref name="repo" /> Beyond basic DOM access, the library includes helpers for mouse, touch, keyboard and scroll events, timers, the clipboard, browser storage, file downloads, full-screen mode, the HTML canvas, audio and video, gamepads, and an on-screen touch joystick.<ref name="blog" />
 
== Example ==
The following page contains a button and a paragraph. Python changes the paragraph's text when the button is clicked.<ref name="blog" />


Pytml was created in 2026 by Aswanth R, a Class 12 student from India. The project was initially developed as a learning tool and prototype for quickly embedding Python in web pages without the need for JavaScript boilerplate.
<syntaxhighlight lang="html">
<script src="https://pytml.vercel.app/pytml.js"></script>


The project has been listed on [[OpenForge|OpenForge.gov.in]], the Indian government's official open-source platform.<ref>{{cite web |title=Pytml |url=https://openforge.gov.in/projects/pytml/ |website=OpenForge |publisher=Government of India |access-date=22 June 2026}}</ref> It has also received a [[Digital object identifier|DOI]] through [[Zenodo]] for academic citation.<ref>{{cite web |title=Pytml |url=https://doi.org/10.5281/zenodo.20786716 |website=Zenodo |access-date=22 June 2026}}</ref>
<button id="hello">Click me</button>
<p id="output"></p>


The project was submitted to various hackathons and developer platforms, including [[Devpost]], where it was featured as a tool for rapid prototyping in Python.<ref>{{cite web |title=Pytml |url=https://devpost.com/software/pytml |website=Devpost |access-date=22 June 2026}}</ref>
<py>
def clicked(event):
    output.text = "Hello!"


== Features ==
hello.on("click", clicked)
</py>
</syntaxhighlight>


Key features of Pytml include:
Here <code>hello</code> and <code>output</code> are the elements with those ids, and no JavaScript is written by the page's author.


* Native Python syntax inside HTML using `<py>` tags or `<script type="text/python">`
== Security ==
* Automatic Pyodide initialization
Pytml's <code>text</code> property writes to the browser's <code>textContent</code> interface, so any markup in the string is displayed as literal characters and is not run. A separate <code>html</code> property writes to <code>innerHTML</code>, which can execute scripts if it is given untrusted input. The project's documentation advises against passing user input to <code>html</code> directly and provides a <code>pytml.escape()</code> function for that purpose.<ref name="repo" />
* I/O redirection: Python's `print()` and `input()` are displayed as HTML elements in the page
* No server required; works with any static HTML host


== Limitations ==
== Limitations ==
The Pytml script is about 15&nbsp;KB, but it loads the Pyodide runtime, which is roughly 6&nbsp;MB and must be downloaded on a visitor's first load. Later visits can use the browser cache.<ref name="lockergnome" /> Packages with C extensions work only if a WebAssembly build exists for them.<ref name="lockergnome" /> The developer lists tutorials, technical blog posts and small data demonstrations as intended uses, and puts heavy back-end processing, database work and production APIs outside the project's scope.<ref name="lockergnome" />
== Relationship to other projects ==
Several other projects run Python in the browser on top of Pyodide. The Pyodide documentation lists them as related projects, and its list includes PyScript, which defines <code>&lt;script type="py"&gt;</code> elements for HTML, marimo notebooks and JupyterLite.<ref name="pyodide-related">{{cite web |title=Related Projects |url=https://pyodide.org/en/latest/project/related-projects.html |website=Pyodide documentation |access-date=22 November 2026}}</ref> Pytml appears in the same list, which describes it as a small library that connects HTML elements to Python variables.<ref name="pyodide-related" /> Python application frameworks such as Streamlit and Gradio present their own interface components. Pytml instead keeps the page as an ordinary HTML document and exposes its elements to Python.<ref name="blog" />
== History ==
Pytml was first released in June 2026. Version 2.5.0 was published in October 2026, and 2.5.1 was the latest release as of November 2026.<ref name="releases">{{cite web |title=Releases · NodeX-AR/Pytml |url=https://github.com/NodeX-AR/Pytml/releases |website=GitHub |access-date=22 November 2026}}</ref> In an October 2026 post on the Pyodide project's blog, its developer described the numbered-tag syntax added in version 2.5 and said he was considering a larger compiler-based design for a later version.<ref name="blog" />


Pytml inherits several limitations from Pyodide:
== Reception ==
The project received limited coverage in its first months. On 19 November 2026 the ''Python Weekly'' newsletter included it in a list of new projects and libraries.<ref>{{cite web |last=Chaudhary |first=Rahul |date=19 November 2026 |title=Python Weekly (Issue 772 November 19 2026) |url=https://www.pythonweekly.com/p/python-weekly-issue-772-november-19-2026 |website=Python Weekly |access-date=22 November 2026}}</ref> The technology site ''LockerGnome'' reviewed it the day before. Its writer, Chris Pirillo, said the library suits short interactive examples in lessons, and noted that the small size quoted for the script does not include the much larger interpreter download. He also pointed out that browser Python is limited by package compatibility, and that the project's claims about privacy apply only to code execution, because the page still loads an interpreter from a content delivery network.<ref name="lockergnome" />


* Large initial download size (approximately 6–7 MB for Pyodide)
== Availability and archiving ==
* Startup latency while WebAssembly boots
The source code is hosted on [[GitHub]], and a copy of the repository has been archived on [[Zenodo]] with a [[digital object identifier]] (DOI) for citation.<ref>{{cite web |title=Pytml |url=https://doi.org/10.5281/zenodo.20786716 |website=Zenodo |doi=10.5281/zenodo.20786716 |access-date=22 November 2026}}</ref> The project is also listed on OpenForge, an open-source software platform run by the [[Government of India]],<ref>{{cite web |title=Pytml |url=https://openforge.gov.in/projects/pytml/ |website=OpenForge |publisher=Government of India |access-date=22 November 2026}}</ref> and in the Research Software Directory.<ref>{{cite web |title=Pytml |url=https://research-software-directory.org/projects/pytml |website=Research Software Directory |access-date=22 November 2026}}</ref> The developer has also published descriptions of the project on DEV Community<ref>{{cite web |last=R |first=Aswanth |title=Pytml: Running Python in the Browser Without a Backend |url=https://dev.to/nodex-ar/pytml-running-python-in-the-browser-without-a-backend-1nn4 |website=DEV Community |access-date=22 November 2026}}</ref> and on Coderlegion.<ref>{{cite web |title=Pytml: Running Python in the Browser Without a Backend |url=https://coderlegion.com/21627/pytml-running-python-in-the-browser-without-a-backend |website=Coderlegion |access-date=22 November 2026}}</ref> The project was also submitted to the hackathon platform Devpost.<ref>{{cite web |title=Pytml |url=https://devpost.com/software/pytml |website=Devpost |access-date=22 November 2026}}</ref>
* Limited support for Python libraries with C-extensions


== See also ==
== See also ==
 
* [[PyScript]]
* [[Pyodide]]
* [[Brython]]
* [[Skulpt]]


== References ==
== References ==
{{reflist}}


{{reflist}}
== External links ==
* {{Official website|https://pytml.js.org}}
* {{GitHub|NodeX-AR/Pytml}}


<!-- Inline citations added to your article will automatically display here. See en.wikipedia.org/wiki/WP:REFB for instructions on how to add citations. -->
[[:Category:JavaScript libraries]]
[[:Category:Python (programming language) libraries]]
[[:Category:Free software programmed in JavaScript]]
[[:Category:WebAssembly]]
{{⚠️🚨COPIED from EverybodyWiki ❗❕⚠️😡😤Please respect Licence CC-BY-SA ❗}}
{{⚠️🚨COPIED from EverybodyWiki ❗❕⚠️😡😤Please respect Licence CC-BY-SA ❗}}
{{Source Wikipedia}}
{{Source Wikipedia}}

Latest revision as of 13:39, 24 November 2026


Pytml
Developer(s)Aswanth R
Initial releaseJune 2026; 5 months ago (2026-06)
Stable release
2.5.1 / October 19, 2026; 40 days ago (2026-10-19)
Written inJavaScript
Engine
    TypeSoftware library
    LicenseApache-2.0
    Websitepytml.js.org

    Search Pytml on Amazon.

    Pytml is an open-source JavaScript library that runs Python code written inside HTML pages. It uses Pyodide, a port of Python to WebAssembly, so the code executes in the visitor's browser and no Python server is needed.[1] It is developed by Aswanth R and released under the Apache License 2.0.[2]

    The library was written with teaching in mind. Its developer has said the aim was to let people who already know some Python make a web page interactive without first learning JavaScript and the browser's Document Object Model (DOM) interfaces.[1] It overlaps in purpose with PyScript, and the project's own documentation describes it as a lightweight alternative to that framework.[2]

    Design

    Syntax

    A page loads Pytml with one <script> tag. Python code is then placed between <py> tags, in a script element of type text/python, or in an external file named by a src attribute.[2][1] When the page loads, Pytml starts Pyodide, finds these blocks and runs them.[3]

    Tags written as <py1>, <py2> and so on mark separate programs. The number is an identifier and not a file name: blocks that share a number share one namespace, and blocks with different numbers do not.[2] Version 2.5 also recognises numbered interface tags (<btnN>, <inputN> and <txtN>) inside a Python block. Before the code reaches Python, a preprocessing step removes these tags from the source, leaves the surrounding text and its indentation unchanged, and inserts the matching button or text field into the page.[1]

    Page elements and events

    Elements that have an id attribute are made available to Python as variables with the same name. Each variable is a thin wrapper around the browser's own DOM object, with properties such as text and value.[1] Event handlers are attached with an on() method, which passes the browser event to a Python function as a dictionary-like object and returns a function that removes the handler again.[1] Because this design relies on direct access to the page's DOM, it runs on the browser's main thread and not in a web worker.[1]

    Input and output

    Text sent to print() is shown on the page, and uncaught exceptions are reported there as well.[3] Python's input() normally pauses a program until the user types something, which a browser cannot do without freezing the page. Pytml therefore rewrites such calls using Python's abstract syntax tree tools so that they wait asynchronously for a text field on the page.[1]

    Packages and browser features

    Packages are installed through Pyodide's micropip tool. Packages that Pyodide already provides, including NumPy, pandas and Matplotlib, can be used.[2] Beyond basic DOM access, the library includes helpers for mouse, touch, keyboard and scroll events, timers, the clipboard, browser storage, file downloads, full-screen mode, the HTML canvas, audio and video, gamepads, and an on-screen touch joystick.[1]

    Example

    The following page contains a button and a paragraph. Python changes the paragraph's text when the button is clicked.[1]

    <script src="https://pytml.vercel.app/pytml.js"></script>
    
    <button id="hello">Click me</button>
    <p id="output"></p>
    
    <py>
    def clicked(event):
        output.text = "Hello!"
    
    hello.on("click", clicked)
    </py>
    

    Here hello and output are the elements with those ids, and no JavaScript is written by the page's author.

    Security

    Pytml's text property writes to the browser's textContent interface, so any markup in the string is displayed as literal characters and is not run. A separate html property writes to innerHTML, which can execute scripts if it is given untrusted input. The project's documentation advises against passing user input to html directly and provides a pytml.escape() function for that purpose.[2]

    Limitations

    The Pytml script is about 15 KB, but it loads the Pyodide runtime, which is roughly 6 MB and must be downloaded on a visitor's first load. Later visits can use the browser cache.[3] Packages with C extensions work only if a WebAssembly build exists for them.[3] The developer lists tutorials, technical blog posts and small data demonstrations as intended uses, and puts heavy back-end processing, database work and production APIs outside the project's scope.[3]

    Relationship to other projects

    Several other projects run Python in the browser on top of Pyodide. The Pyodide documentation lists them as related projects, and its list includes PyScript, which defines <script type="py"> elements for HTML, marimo notebooks and JupyterLite.[4] Pytml appears in the same list, which describes it as a small library that connects HTML elements to Python variables.[4] Python application frameworks such as Streamlit and Gradio present their own interface components. Pytml instead keeps the page as an ordinary HTML document and exposes its elements to Python.[1]

    History

    Pytml was first released in June 2026. Version 2.5.0 was published in October 2026, and 2.5.1 was the latest release as of November 2026.[5] In an October 2026 post on the Pyodide project's blog, its developer described the numbered-tag syntax added in version 2.5 and said he was considering a larger compiler-based design for a later version.[1]

    Reception

    The project received limited coverage in its first months. On 19 November 2026 the Python Weekly newsletter included it in a list of new projects and libraries.[6] The technology site LockerGnome reviewed it the day before. Its writer, Chris Pirillo, said the library suits short interactive examples in lessons, and noted that the small size quoted for the script does not include the much larger interpreter download. He also pointed out that browser Python is limited by package compatibility, and that the project's claims about privacy apply only to code execution, because the page still loads an interpreter from a content delivery network.[3]

    Availability and archiving

    The source code is hosted on GitHub, and a copy of the repository has been archived on Zenodo with a digital object identifier (DOI) for citation.[7] The project is also listed on OpenForge, an open-source software platform run by the Government of India,[8] and in the Research Software Directory.[9] The developer has also published descriptions of the project on DEV Community[10] and on Coderlegion.[11] The project was also submitted to the hackathon platform Devpost.[12]

    See also

    References

    1. ↑ 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 R, Aswanth (19 October 2026). "Pytml: Python in Your HTML with a Single Script Tag". Pyodide blog. Retrieved 22 November 2026.
    2. ↑ 2.0 2.1 2.2 2.3 2.4 2.5 "NodeX-AR/Pytml". GitHub. Retrieved 22 November 2026.
    3. ↑ 3.0 3.1 3.2 3.3 3.4 3.5 Pirillo, Chris (18 November 2026). "Pytml runs Python inside HTML tags by loading a browser-side interpreter". LockerGnome. Retrieved 22 November 2026.
    4. ↑ "Releases · NodeX-AR/Pytml". GitHub. Retrieved 22 November 2026.
    5. ↑ Chaudhary, Rahul (19 November 2026). "Python Weekly (Issue 772 November 19 2026)". Python Weekly. Retrieved 22 November 2026.
    6. ↑ "Pytml". Zenodo. doi:10.5281/zenodo.20786716. Retrieved 22 November 2026.
    7. ↑ "Pytml". OpenForge. Government of India. Retrieved 22 November 2026.
    8. ↑ "Pytml". Research Software Directory. Retrieved 22 November 2026.
    9. ↑ R, Aswanth. "Pytml: Running Python in the Browser Without a Backend". DEV Community. Retrieved 22 November 2026.
    10. ↑ "Pytml: Running Python in the Browser Without a Backend". Coderlegion. Retrieved 22 November 2026.
    11. ↑ "Pytml". Devpost. Retrieved 22 November 2026.

    Category:JavaScript libraries Category:Python (programming language) libraries Category:Free software programmed in JavaScript Category:WebAssembly


    This article "Pytml" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Pytml. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.