
























Element has been subsumed into the new pydom package, which you can check out here: https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyweb/pydom.py

Element has been subsumed into the new pydom package, which you can check out here: https://github.com/pyscript/pyscript/blob/main/pyscript.core/src/stdlib/pyweb/pydom.py 

from pydom import Element? I do think (1) we removed some of the names from being imported automatically and (2) Element is now in the pydom package

from pydom import Element? I do think (1) we removed some of the names from being imported automatically and (2) Element is now in the pydom package 
from pyscript.pydom import Element (remembering off the top of my head here - please check the namespaces).

from pyscript.pydom import Element (remembering off the top of my head here - please check the namespaces). 








fetch call would look from Python, including what to import to get access to it, and what types it expects, which Exceptions it might raise, etc. Is this written down somewhere?

fetch call would look from Python, including what to import to get access to it, and what types it expects, which Exceptions it might raise, etc. Is this written down somewhere? fetch is documented in the MDN docs. You access the browser based APIs (in which fetch is found) via the FFI. E.g. from pyscript import document gives you the document object from the browser.
fetch function into Python land? Do I do from pyscript import fetch, or is it part of the document object, or something else? That's the part that's confusing me, and as far as I can tell, it's not documented anywhere. (edited)

fetch function into Python land? Do I do from pyscript import fetch, or is it part of the document object, or something else? That's the part that's confusing me, and as far as I can tell, it's not documented anywhere. (edited)from pyscript import window, followed by window.fetch(…). Window, in this case, is a direct proxy of the JS global namespace. More specifically, it’s the main thread’s global namespace, even if you’re running pyscript in a workerfrom js import fetch.









NotImplementedException when called. Having such a stub library would allow you to have a better developer experience in modern IDEs like VS Code and tools like mypy. But if you're going to wrap all the web stuff in a Python library, that might not be needed? (edited)



fetch. After messing around a lot, it turns out that fetch in Python takes its options as kwargs, rather than taking it as a dictionary (in JavaScript, the options to a fetch are typically provided as a JavaScript object, which I assumed would translate as a Python dictionary, but this assumption turned out to be wrong).




fetch - can you share a sample of your code?


response = await window.fetch(
path,
{
"body": json_str,
"cache": "no-cache",
"method": "POST",
},
)
but that does not work. If you try it, the options will be ignored, and a HTTP GET request will instead be sent (which does not work).
If you want to try that yourself, you'd need to either disable mypy or modify the pyi file (edited)












pyscript.fetch utility that should satisfy any possible user/requirement and still produce pythonic results ... for anything else, you can always opt in for raw js.fetch API which is described on MDN or as Web standard.

pyscript.fetch utility that should satisfy any possible user/requirement and still produce pythonic results ... for anything else, you can always opt in for raw js.fetch API which is described on MDN or as Web standard. 





For more details about pydom.create please refer to its reference documentation. on this page: https://pyscript.github.io/docs/2024.3.2/user-guide/dom/
Which reference documentation is this referring to? Perhaps it would be a good idea to link it? I tried googling a bit but couldn't find anything



For more details about pydom.create please refer to its reference documentation. on this page: https://pyscript.github.io/docs/2024.3.2/user-guide/dom/
Which reference documentation is this referring to? Perhaps it would be a good idea to link it? I tried googling a bit but couldn't find anything 

as_object_map or other methods, they are not present.



as_object_map or other methods, they are not present. jsffi in MicroPython exposes only to_js and create_proxy but I am not sure it implements dict_converter in the to_js version, also because nobody ever asked for that to date in MicroPython ... do you want the dictionary to be a JS Map instead? ... and why is that, if I might ask? I can help with solutions but I'd like to understand more

@when but I think it should work out of the box now with the unified pyscript.ffi ... will check why that would not be the case.

@when but I think it should work out of the box now with the unified pyscript.ffi ... will check why that would not be the case. 
@when should work with MicroPython.
@when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! 2024.3.2 release.

@when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! add_event_listener but no proxy_create in MicroPython when we add that listener within the fallback ... there might be some scenario that requires that but it's eventually an easy thing to fix, if needed.


.mjs file from the CDN ... in polyscript we resolve that as such:
module: (version = '1.22.0-272') =>
`https://cdn.jsdelivr.net/npm/@micropython/micropython-webassembly-pyscript@${version}/micropython.mjs`,
pick any of those version numbers and create your own custom MicroPython URL (or build it locally and point at its dist files)



jsffi recently landed in MicroPython, you might be disappointed by finding something else in previous versions. It's true that we do try/catches around Pyodide ability to date, as that's the most common interpreter so far, but we can't guarantee that'd be the case in the near future. To some extend, Pyodide is planning to improve its default to_js story, and once that lands we'll probably remove entirely the need for a dict_converter ... in there you won't be able to make it work with previous versions of Pyodide, so this feature is usually more about "forward testing" than regression tests, as we're strongly dependent on interpreters APIs provided in time. I hope this makes sense, if we start branching out every single Pyodide and MicroPython version to date to allow backward compatibility with previous interpreters, our core will be way more huge and our ability to pin down issues way more reduced, for both our projects and upstream. Does anything I've said make sense?

jsffi recently landed in MicroPython, you might be disappointed by finding something else in previous versions. It's true that we do try/catches around Pyodide ability to date, as that's the most common interpreter so far, but we can't guarantee that'd be the case in the near future. To some extend, Pyodide is planning to improve its default to_js story, and once that lands we'll probably remove entirely the need for a dict_converter ... in there you won't be able to make it work with previous versions of Pyodide, so this feature is usually more about "forward testing" than regression tests, as we're strongly dependent on interpreters APIs provided in time. I hope this makes sense, if we start branching out every single Pyodide and MicroPython version to date to allow backward compatibility with previous interpreters, our core will be way more huge and our ability to pin down issues way more reduced, for both our projects and upstream. Does anything I've said make sense? 









@when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! 




async attribute in the <script> is to enable top level await ... here there's no top level await anywhere in use, so I think it's not needed ... the rest is an upstream bug for MicroPython, as even enforcing create_proxy(that_listener) doesn't fix the the issue, even using manually addEventListener via DOM API. In short: this is not a @when decorator issue and not a PyScript issue or nothing we can solve, we need to inform Damien async listeners fail big time in mpy.<script async> is there, even if not needed, and everything works as expected until I define that function as async. With Pyodide there's not such issue.



fetch(url).text().then(lambda result: do_your_thing(result))

fetch(url).text().then(lambda result: do_your_thing(result)) 

For more details about pydom.create please refer to its reference documentation. on this page: https://pyscript.github.io/docs/2024.3.2/user-guide/dom/
Which reference documentation is this referring to? Perhaps it would be a good idea to link it? I tried googling a bit but couldn't find anything 

pyscript.fetch(...) is exactly like fetch in JS except you can also already forward the desired response outcome so that fetch(url).text() or fetch(url).json() already returns what you've asked for (but throw if the response was not ok).response = await fetch(url);text = await response.text(); so you have full control too

response = await fetch(url);text = await response.text(); so you have full control too 

then and proxied promises in Pyscript are compatible with that ... apologies for misleading you with that then it was to eventually give you the ability to detach the running code so you don't always or necessarily need to await to completition but I feel like going off-topic now 



then and proxied promises in Pyscript are compatible with that ... apologies for misleading you with that then it was to eventually give you the ability to detach the running code so you don't always or necessarily need to await to completition but I feel like going off-topic now 
__init__.py, foo.py, bar.py, baz.py) to the virtual filesystem.
{
"files": {
"{DOMAIN}": "https://my-server.com",
"{PATH}": "a/path",
"{VERSION}": "1.2.3",
"{FROM}": "{DOMAIN}/{PATH}/{VERSION}",
"{TO}": "./my_module",
"{FROM}/__init__.py": "{TO}/__init__.py",
"{FROM}/foo.py": "{TO}/foo.py",
"{FROM}/bar.py": "{TO}/bar.py",
"{FROM}/baz.py": "{TO}/baz.py",
}
}
Is there any way to do this without writing each file inside the folder? Maybe something like "{FROM}/*": "{TO}/*"? (edited)

__init__.py, foo.py, bar.py, baz.py) to the virtual filesystem.
{
"files": {
"{DOMAIN}": "https://my-server.com",
"{PATH}": "a/path",
"{VERSION}": "1.2.3",
"{FROM}": "{DOMAIN}/{PATH}/{VERSION}",
"{TO}": "./my_module",
"{FROM}/__init__.py": "{TO}/__init__.py",
"{FROM}/foo.py": "{TO}/foo.py",
"{FROM}/bar.py": "{TO}/bar.py",
"{FROM}/baz.py": "{TO}/baz.py",
}
}
Is there any way to do this without writing each file inside the folder? Maybe something like "{FROM}/*": "{TO}/*"? (edited)



.zip solution should work in both Pyodide and MicroPython case.

pyscript.foo builtins.


pyscript namespace.

js module is provided by each interpreter as a proxy for JavaScript's globalThis object. It's via this reference that we can start to build up the stuff in the pyscript namespace. Also, PyScript is a LOT more than just the pyscript namespace. There's configuration, web workers, and a whole bunch of boilerplate you never have to use to get the interpreters working. 


















py-click (see https://pyscript.com/@examples/pyscript-jokes/latest?files=README.md,index.html). The other school of thought is to have a Python API to create DOM elements programmatically, such as pyscript.web (see https://docs.pyscript.net/2024.10.2/user-guide/dom/#pyscriptweb) or LTK as used by PySheets (see https://pyscript.github.io/ltk/).



py-click (see https://pyscript.com/@examples/pyscript-jokes/latest?files=README.md,index.html). The other school of thought is to have a Python API to create DOM elements programmatically, such as pyscript.web (see https://docs.pyscript.net/2024.10.2/user-guide/dom/#pyscriptweb) or LTK as used by PySheets (see https://pyscript.github.io/ltk/). 














[[fetch]] in them but can't find it in the docs. Has it been replaced by [files] or can I just not find it

[[fetch]] in them but can't find it in the docs. Has it been replaced by [files] or can I just not find it 

[[fetch]] please ?

[[fetch]] please ? [files] these days.

[files] from now on, and perhaps we should remove support for [[fetch]]..? Thoughts in the community call perhaps..?
[files] only work if you are downloading from an external server?
For me, this works:
[[fetch]]
files = [ "card_detector.py", "card_matcher.py", "pokemon_cards.min.json" ]
But this does not:
[files]
"/card_detector.py" = "./card_detector.py"
"/card_matcher.py" = "./card_matcher.py"
"/pokemon_cards.min.json" = "./pokemon_cards.min.json"

"/card_dectector.py" = "", same issue.
fetch - that's the "old" way. Just use files instead. The definitive behaviour of files is here: https://docs.pyscript.net/2025.2.2/user-guide/configuration/#files
The examples you give that didn't work should work AFAICT. Can you paste any error messages you see..? Thank you!

"/card_dectector.py" = "", same issue. [files]
"./card_detector.py" = ""


"/code.py" = "./subdir/code.py" which is clearly wrong 










pyscript.workers is an utility that orchestrates more, see https://docs.pyscript.net/2025.3.1/api/#pyscriptworkers ... PyWorker is a raw utility but we have tests for that and it's all about exposing features via sync namespace, it doesn't reflect pyscript.workers intent and features.PyWorker:


pyscript.workers is an utility that orchestrates more, see https://docs.pyscript.net/2025.3.1/api/#pyscriptworkers ... PyWorker is a raw utility but we have tests for that and it's all about exposing features via sync namespace, it doesn't reflect pyscript.workers intent and features. 









