Code viewer for World: Python demo
// Minimal Python "Hello World"

// Cloned from World "Pyscript Hello World" by Brendan McGrath 
// https://ancientbrain.com/world.php?world=9027448122
 
// PyScript: https://pyscript.net/
// PyScript is built on top of Pyodide, which is a Python distribution compiled to WebAssembly. 
// When you load:https://pyscript.net/releases/2025.8.1/core.js
// This JavaScript file downloads and initializes a WebAssembly-based Python interpreter.
// What happens under the hood:
//   - PyScript core.js loads the Pyodide WASM runtime
//   - Python interpreter runs entirely in WebAssembly in your browser
//   - Python packages (like pandas, matplotlib) are compiled to WASM
//   - No server required - everything runs client-side


document.write ( `

  <div style='padding:30'>
    <script type="module" src="https://pyscript.net/releases/2025.8.1/core.js"><\/script>
    <div id="output"></div>
      
    <script type="py">
      
        from pyscript import document
        
        document.querySelector("#output").innerHTML = "Python can call JS functions to write to page. <br> This runs when the Python is interpreted."
        
        print ( "Python 'print' writes to console" )
            
    </script>
 </div>
 
` );

console.log ("JS outside the Python will run BEFORE the Python is interpreted.");