Guild icon
PyScript 💻
💬 | General / ╰╸pyscript-docs
For feedback, questions and suggestions relating to our docs found at https://docs.pyscript.net/
Avatar
tedpatrick 01/11/2022 15:10
Hello Docs!
👋🏼 9
Avatar
Hi. I am new to pyscript - was reading the old pyscript docs . It seems that it has been taken off. The new pyscript docs contain very minimal information. I am wondering how to access the old documentaion. Is it deprecated ? or is the functionality explained in old docs deprecated ?
Avatar
Hi @arvind - the version of the docs that you see right now is for the next version of PyScript, which is a complete re-write with much of the old docs out of date or just plain wrong. The new docs will mature as the release candiates for the next version are released. They'll be comprehensive and accurate by the time we do a final release of the next version. As for the old docs... archive.org has you covered: https://web.archive.org/web/20230521045221/https://docs.pyscript.net/latest/
Avatar
Jeff Glass 01/10/2023 19:11
Another option (esp for those who's workplace/geography has archive.org blocked) is to view them on GitHub under the tag of the previous release: https://github.com/pyscript/pyscript/tree/2023.05.1/docs
👍 1
Avatar
Thank you @Jeff Glass 🚀
Avatar
really, we should continue hosting the old docs somewhere. Python still hosts documentation for 3.5 (released in 2015), Django for 1.8 (also released in 2015), numpy for 1.3 (released in 2009). Why can't we host docs for something which we released a few months ago?
Avatar
Avatar
antocuni
really, we should continue hosting the old docs somewhere. Python still hosts documentation for 3.5 (released in 2015), Django for 1.8 (also released in 2015), numpy for 1.3 (released in 2009). Why can't we host docs for something which we released a few months ago?
tedpatrick 02/10/2023 14:40
My take: Key reason is burying the old in favor of the new. SEO plays a key role in adoption, and if we remove the old, the new will become the default in SEO and search. Next is a huge reset... and we should reset the docs.
Avatar
Jeff Glass 02/10/2023 14:47
Not a bad reason, I don't know that much about SEO. But I'm with Antonio: - anyone who is still using PyScript Classic (which is our current release) is now out of luck. And anyone who linked to our older docs now has a bunch of broken links on their hands with no obvious fix.
Avatar
I mean, the original sin is that the URLs of our docs were not versioned
Avatar
Avatar
antocuni
I mean, the original sin is that the URLs of our docs were not versioned
Jeff Glass 02/10/2023 14:49
Avatar
ah ok
14:50
then IMHO the correct solution is to resurrect them and put a banner on top which says "this is the old version, click here for the new one"
Avatar
Hi @ntoll -thanks a lot. however, the archived site is painfully slow
Avatar
@arvind the GitHub link from @Jeff Glass will be much faster: https://github.com/pyscript/pyscript/tree/2023.05.1/docs (we don't have any control over the performance of archive.org)
Avatar
hi @ntoll - thanks a lot. I understand that the new version in progress now will provide better functionality , but what are the things from the old version, which won't work at all - a small list of that would be helpful. Thanks again.
Avatar
@arvind that's a really great question. I think we should write a blog post enumerating these things for folks.
Avatar
Avatar
ntoll
@arvind that's a really great question. I think we should write a blog post enumerating these things for folks.
I think it should be a section of the docs (maybe in the changelog), not just a blog post
Avatar
Perhaps a "migrating from classic" section.
❤️ 1
Avatar
Avatar
ntoll
Perhaps a "migrating from classic" section.
that would be awesome!
Avatar
On it.
Avatar
Fabiano.py 08/10/2023 19:13
Help What I liked most about pyscript was using Element instead of the Document method: getElementById() in the new version of pyscript will Element still work? The question is, will I return the element natively?
19:32
Not entirely sure what you’re asking about returning the element natively
Avatar
Avatar
Jeff Glass
So 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
Fabiano.py 08/10/2023 23:59
First of all, thanks for the answer: I asked the question because I changed the default cdn to 2023.09.1.RC2/core In old codes that have Element,display, target=, @when('click','#btn') Just to test and also to update the ones I have here and I received the error: Uncaught PythonError: Traceback (last most recent call): File "/home/pyodide/pyscript/event_handling.py", line 36, in the wrapper function() File "<exec>", line 7, in summary NameError: name 'Element' is not defined
Avatar
Avatar
Fabiano.py
First of all, thanks for the answer: I asked the question because I changed the default cdn to 2023.09.1.RC2/core In old codes that have Element,display, target=, @when('click','#btn') Just to test and also to update the ones I have here and I received the error: Uncaught PythonError: Traceback (last most recent call): File "/home/pyodide/pyscript/event_handling.py", line 36, in the wrapper function() File "<exec>", line 7, in summary NameError: name 'Element' is not defined
Jeff Glass 09/10/2023 00:38
Did you do 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
Avatar
Avatar
Jeff Glass
Did you do 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
Fabiano.py 09/10/2023 04:27
Ok, I got it 🙂
Avatar
Yeah... so after a LOT of discussion we decided to NOT automatically import special things. That's a choice for the developer to make, so just from pyscript.pydom import Element (remembering off the top of my head here - please check the namespaces).
👍 1
Avatar
Avatar
ntoll
Yeah... so after a LOT of discussion we decided to NOT automatically import special things. That's a choice for the developer to make, so just from pyscript.pydom import Element (remembering off the top of my head here - please check the namespaces).
Fabiano.py 10/10/2023 01:44
I apologize for my mistake. I went to help pyscript thinking it was an error, there I was informed about the documentation and then I ended up here. Apologies again.🙂 (edited)
Avatar
No need to apologise! 👍 I spend most of my day as an engineer asking myself, "why on earth doesn't this work?". 😁
🙂 1
😆 1
Avatar
Avatar
ntoll
No need to apologise! 👍 I spend most of my day as an engineer asking myself, "why on earth doesn't this work?". 😁
One of the potentially depressing things about being a developer is the continual reminder we aren't as smart as we think we are!
07:54
I find after fifty years or so you eventually get. used to it.
😆 2
Avatar
Amen brother... 🙂
Avatar
AdinSoftic 11/01/2024 20:16
I think it would be great to create GPTs Assistant for the documentation and generating examples. I saw it with CrewAI project (not related at all) and found it realy easy and helpful for the newbies (me).
👍 1
Avatar
@AdinSoftic thank you for the suggestion. I'm intrigued, how should we best reveal this sort of thing to our users? Do you have examples of good practice in this area? (You mention CrewAI - can you point me somewhere via a URL?)
Avatar
Avatar
ntoll
@AdinSoftic thank you for the suggestion. I'm intrigued, how should we best reveal this sort of thing to our users? Do you have examples of good practice in this area? (You mention CrewAI - can you point me somewhere via a URL?)
AdinSoftic 12/01/2024 10:57
They put the link to the custom gpt in their git with the text Talk with the Docs https://github.com/joaomdmoura/crewAI
Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks. - GitHub - joaom...
👍 1
Avatar
Does Pyscript have an API reference? I was looking through the documentation but couldn't find anything, except for links to the JavaScript API reference on MDN.
18:33
For example, I want to look up how a 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?
Avatar
Avatar
Dagusiu
For example, I want to look up how a 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.
Avatar
But where do I get the actual 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)
Avatar
Avatar
Dagusiu
But where do I get the actual 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)
Jeff Glass 26/02/2024 04:01
You’ll want to do 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 worker
04:02
If you’re running in a worker and you need access to the worker’s global namespace for some reason, you can do from js import fetch.
Avatar
Thanks! That explains a lot. Maybe adding one or two examples of that in the documentation could be a good idea.
Avatar
Jeff Glass 26/02/2024 05:13
For sure! I also maintain a side-reference called pyscript.recipes with some more exacmple, including stuff like this https://pyscript.recipes/2024.1.1/js-integration/import-js/
Avatar
How do I know which Python exceptions these FFI calls can raise? Is that documented anywhere?
Avatar
Avatar
Neon22
@Jeff Glass Does this page need a polyscript to pyscript update ? https://pyscript.recipes/2024.1.1/js-integration/js-modules/
Andrea Giammarchi 26/02/2024 08:46
I find this explicit enough but true that a replace in there would also work these days 👍
Avatar
always an issue with docs in a fast changin environment. but we all appreciate the efforts
Avatar
@Dagusiu my apologies for not being more clear (I was typing quickly while checking weekend discord), and huge thanks (as always) to @Jeff Glass for stepping in with a clear and concise answer. Thanks for the docs suggestions, we'll take them on board. To be honest @Fabio is working on a Python library that should just abstract away all the JS stuff. But it's early days (as is most things WRT PyScript). Hence your feedback is really welcome and helpful..! 🚀
Avatar
Avatar
ntoll
@Dagusiu my apologies for not being more clear (I was typing quickly while checking weekend discord), and huge thanks (as always) to @Jeff Glass for stepping in with a clear and concise answer. Thanks for the docs suggestions, we'll take them on board. To be honest @Fabio is working on a Python library that should just abstract away all the JS stuff. But it's early days (as is most things WRT PyScript). Hence your feedback is really welcome and helpful..! 🚀
There is absolutely no need to apologize, I'm just glad to get quick answers to my questions and I'm glad I can help. I was also thinking about maybe creating a stub library in python, where all the web APIs are "implemented" (as in, they exist with the correct type hints and some useful docstrings) but only throw a 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)
Avatar
@Dagusiu always happy to help. Just want to manage expectations (this is a relatively young project). 😉 But because of its "youth" there's also lots of cool stuff that folks can do to help build things out. @Fabio is the person to talk to about the Pythonic "web api" wrapper. But I can say with some certainty (because it's what we all agree on), our approach is collaborative and open, so comments, suggestions and constructive critique is always welcome.
❤️ 1
Avatar
@Dagusiu thanks for the topic, this is great discussion and very valuable! In terms of creating a stub module, I think we should chat and clarify what you had in mind vs what I'm currently working on because I really think there's a lot of potential for the 2 things to overlap and I would definitely love help 🙂 My goal is not to map everything (it's massive) but parts of it as pythonic as possible
Avatar
@Fabio That makes a lot of sense. No point in two separate projects that try to mostly solve the same goal (albeit in very different ways). What would be a good channel to talk more about it? Maybe #╰╸pyscript-collective ? Or just #╰╸chat ? (edited)
Avatar
A very concrete example of why Python specific documentation of the web APIs would be useful: I just spent a full hour trying to get a HTTP POST working over 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).
07:06
I am building a small .pyi file for pyscript, which can handle the APIs I care about, but writing this without Python specific documentation is a challenge. I will try to figure out a good way to share this pyi file, so that others won't need to duplicate my efforts
Avatar
Phelsong (Josh) 03/03/2024 15:08
that's a pyodide thing. I personally think that's the hardest thing about pyscript, just determining WHERE to even look... the pyodide docs clearly say kwargs, but it's not super obvious that's where you should have looked. https://pyodide.org/en/stable/usage/api/python-api/http.html
15:09
to find the available params, you then need to look at the JS fetch api and match them.
15:09
@Dagusiu
Avatar
What's interesting is that I did look there, but I figured that it was a different function altogether, because in Pyscript it's called "fetch" while this one is called "pyfetch". If Pyscript is the one who changed the name, I still think it's Pyscript's responsibility to document it. Just a single note somewhere that the fetch function is actually pyodide's pyfetch function would have solved the problem immediately. That said, I fully understand why this is not the case (yet), Pyscript is young and still unstable in several ways. I hope this doesn't come off as entitled or whiney.
Avatar
Phelsong (Josh) 03/03/2024 15:19
pyscript doesn't have a native fetch that i'm aware of?
15:22
that to say, w/e implementation is a JS wrapper and is going to function the same way
Avatar
Avatar
Dagusiu
What's interesting is that I did look there, but I figured that it was a different function altogether, because in Pyscript it's called "fetch" while this one is called "pyfetch". If Pyscript is the one who changed the name, I still think it's Pyscript's responsibility to document it. Just a single note somewhere that the fetch function is actually pyodide's pyfetch function would have solved the problem immediately. That said, I fully understand why this is not the case (yet), Pyscript is young and still unstable in several ways. I hope this doesn't come off as entitled or whiney.
Jeff Glass 03/03/2024 17:44
Yeah as far as I know, PyScript doesn’t shadow fetch - can you share a sample of your code?
17:45
Not that there aren’t things we could do to help folks find the right resources, just curious about this specific case as well 👍
Avatar
Sure. I'm not quite ready to make my own project open source yet (still haven't decided on a suitable license for it) but give me a day or so and I'll make a minimal example to showcase what's going on (that's probably more helpful anyway). That also doubles as an easy way to share and demonstrate the (very limited) process I've made towards my pyi file for pyscript
👍 1
Avatar
Jeff Glass 03/03/2024 18:50
That sounds perfect - yeah if you’re able to come up with a short snippet that shows what’s happening, that’d be super helpful
Avatar
Check out this repository: https://github.com/ahrnbom/pyscript-litestar-demo In particular, right here: https://github.com/ahrnbom/pyscript-litestar-demo/blob/d111d57652586b19cc176aa5e16dbc2763a8c0e1/demo/client/client.py#L36 Based on the Javascript API, I would have expected this to instead be 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)
21:12
@Jeff Glass
Avatar
Furthermore, I created a branch with that behaviour, for you to try out: https://github.com/ahrnbom/pyscript-litestar-demo/pull/1
Avatar
Phelsong (Josh) 04/03/2024 00:01
i don't think a dict can directly be serialized to a JS object... you'd need a layer to create a new prototype instance first
00:06
the framework i'm working on is almost identical to what your demo is doing https://github.com/Phelsong/Senza
Contribute to Phelsong/Senza development by creating an account on GitHub.
00:06
if there is anything in there that helps
00:11
some stuff is still a little jank, i'm working in an active project and transplanting pieces
Avatar
I think the thing that would help would be if Pyscript's documentation would detail exactly how the translation of Javascript APIs to Python works. I don't need any particular help in this case, since I have figured out how it works, my point is just that it was difficult to understand how it works because it's not documented
05:33
like, when I read Pyscript's documentation on Web APIs, it's only linking to MDN's Javascript documentation, with no explanation of how to translate these APIs to Python. And this example shows that this translation is non-trivial, so some kind of explanation of how it works would be very helpful
Avatar
Hi friends! I going to give a talk about PyScript and I want to be sure that my scheme is correct. I investigated all the docs and I think it's very accurate, but what do you think?
Avatar
@Jimena hey hey... congratulations on the talk, and thank you for talking about PyScript..! It looks good to me. Just a suggestion, and please feel free to ignore me, you know how you have "Numpy" next to PyScript (showing that Numpy belongs in the PyScript world)? Perhaps put "DOM" or something next to "JS" to show that you have access to the DOM and other browser APIs in that world via the FFI..? But what you have definitely LGTM 🚀
👍 1
16:44
Please do share details of the talk too..! 👍
Avatar
Avatar
Jimena
Hi friends! I going to give a talk about PyScript and I want to be sure that my scheme is correct. I investigated all the docs and I think it's very accurate, but what do you think?
Andrea Giammarchi 22/03/2024 12:50
when it comes to Polyscript itself it works with Lua too (Wasmoon) and technically any WASM targeting PL + it provides some high level API or feature via configuration, the FFI is instead provided by each individual interpreter. The chart looks good though, but we also work on WebKitCore (the engine behind Safari and WebKit based browsers) ... and what Nicholas said too 😉 (edited)
Avatar
chris.laffra 24/03/2024 15:25
@Jimena Great to hear you are going to do a talk on PyScript. Where will the talk be done? If you have not seen it yet, you may want to watch a talk I did at PyData Eindhoven in December: https://www.youtube.com/watch?v=5nseG-iU62g
Avatar
So, i was trying to use fetch(), but it didn't seem to work the way it was documented on pyscript.net. I was just digging around on GitHub and realised the public docs are documenting a very recent change that is not in 2024.3.1. Is there an intention that the docs are for the release, or is that more of a work in progress? PS: pyscript is cool 😎 i built a skeleton of a client server website with fastAPI and pyscript in a few hours as my first experiment in web for a long time.
Avatar
Avatar
AndrewD
So, i was trying to use fetch(), but it didn't seem to work the way it was documented on pyscript.net. I was just digging around on GitHub and realised the public docs are documenting a very recent change that is not in 2024.3.1. Is there an intention that the docs are for the release, or is that more of a work in progress? PS: pyscript is cool 😎 i built a skeleton of a client server website with fastAPI and pyscript in a few hours as my first experiment in web for a long time.
If you want a concrete example of using fetch with Pyscript, the way it was prior to that change, you can check out this repo: https://github.com/ahrnbom/pyscript-litestar-demo It uses Litestar instead of FastAPI, but they're very similar
Demonstration of how to use Pyscript and Litestar together, to run web software with Python on both frontend and backend - ahrnbom/pyscript-litestar-demo
Avatar
Avatar
AndrewD
So, i was trying to use fetch(), but it didn't seem to work the way it was documented on pyscript.net. I was just digging around on GitHub and realised the public docs are documenting a very recent change that is not in 2024.3.1. Is there an intention that the docs are for the release, or is that more of a work in progress? PS: pyscript is cool 😎 i built a skeleton of a client server website with fastAPI and pyscript in a few hours as my first experiment in web for a long time.
Andrea Giammarchi 25/03/2024 13:08
the latest release will bring a 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.
👍 1
Avatar
Avatar
Andrea Giammarchi
the latest release will bring a 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.
Yes, the documentated interface looks great and does everything i need. I was just reporting that the live documentation seems to cover a change that isn't in the current release, but will be in the next release, from the symptoms I saw in my experiments. It also looks like an mpy difference i noticed is already fixed. It's great to see how this has evolved so far from the tutorial i looked at that got me intrigued.
Avatar
Avatar
Dagusiu
If you want a concrete example of using fetch with Pyscript, the way it was prior to that change, you can check out this repo: https://github.com/ahrnbom/pyscript-litestar-demo It uses Litestar instead of FastAPI, but they're very similar
Thanks, looks similar to what i came up with.
Avatar
@AndrewD well caught. It looks like the docs for the next version of PyScript have been deployed as the current version. Sorry about that, and the confusion it caused. Next release (hopefully today) will bring things in sync.
👍 2
Avatar
Avatar
ntoll
@AndrewD well caught. It looks like the docs for the next version of PyScript have been deployed as the current version. Sorry about that, and the confusion it caused. Next release (hopefully today) will bring things in sync.
I was pleasantly surprised to determine the the docs were leading the project, instead of lagging 🙂 I'm also happy to report anything i find: it's as deep as my contribution can be at this stage
Avatar
I noted this line in the documentation: 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
Avatar
Avatar
AndrewD
Yes, the documentated interface looks great and does everything i need. I was just reporting that the live documentation seems to cover a change that isn't in the current release, but will be in the next release, from the symptoms I saw in my experiments. It also looks like an mpy difference i noticed is already fixed. It's great to see how this has evolved so far from the tutorial i looked at that got me intrigued.
Andrea Giammarchi 26/03/2024 20:55
FYI with 2024.3.2 you should be good now
Avatar
Avatar
Dagusiu
I noted this line in the documentation: 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
This is a current link https://pyscript.github.io/docs/2024.3.2/user-guide/builtins/#pyscriptfetch, but when I was navigating the documentation over the weekend the version number didn't seem to be in the URL? Or somehow I navigated to the bleeding edge docs?
Avatar
Avatar
Andrea Giammarchi
FYI with 2024.3.2 you should be good now
thanks
Avatar
Eruvanos [UTC+1] 27/03/2024 08:43
Where can I find documentation about the JSProxy of micropython? I found the hint, that they are close to pyodide, but when I try to use as_object_map or other methods, they are not present.
Avatar
Avatar
Andrea Giammarchi
FYI with 2024.3.2 you should be good now
To round this out I just tried with 2024.3.2 and it now works as per the documentation version I first read - thanks for letting me know this was available. I also tried MPY with the same example and it is now working (almost) the same as py - I just needed an mpy-click="..." attribute as @when doesn't seem to be supported with mpy. (edited)
Avatar
Avatar
Eruvanos [UTC+1]
Where can I find documentation about the JSProxy of micropython? I found the hint, that they are close to pyodide, but when I try to use as_object_map or other methods, they are not present.
Andrea Giammarchi 27/03/2024 09:38
the 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
Avatar
Avatar
AndrewD
To round this out I just tried with 2024.3.2 and it now works as per the documentation version I first read - thanks for letting me know this was available. I also tried MPY with the same example and it is now working (almost) the same as py - I just needed an mpy-click="..." attribute as @when doesn't seem to be supported with mpy. (edited)
Andrea Giammarchi 27/03/2024 09:39
good point about @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.
09:39
@Jeff Glass ^^^ ... any clue?
Avatar
Avatar
Andrea Giammarchi
good point about @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.
No error with specifying it, but the event handler did not run. I only noticed @when today when reviewing the updated docs - in my initial experiment I was using py_click or mpy_click
Avatar
Hmm... @when should work with MicroPython.
Eruvanos [UTC+1] started a thread. 27/03/2024 11:11
Avatar
@AndrewD 👋 I just tried @when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! 👍
11:20
This is with the latest 2024.3.2 release.
Avatar
Avatar
ntoll
@AndrewD 👋 I just tried @when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! 👍
Andrea Giammarchi 27/03/2024 14:27
my only possible concern is around the fact we use pyodide specific 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.
Avatar
chris.laffra 27/03/2024 15:26
The docs tell me that I can set a specific interpreter version in the TOML. I have done so for MicroPython. However, how do I know what versions I can choose from? Is there a list? Is this it: https://www.jsdelivr.com/package/npm/@micropython/micropython-webassembly-pyscript?tab=files?
A free, fast, and reliable CDN for @micropython/micropython-webassembly-pyscript. MicroPython WebAssembly port, PyScript variant
Avatar
Avatar
chris.laffra
The docs tell me that I can set a specific interpreter version in the TOML. I have done so for MicroPython. However, how do I know what versions I can choose from? Is there a list? Is this it: https://www.jsdelivr.com/package/npm/@micropython/micropython-webassembly-pyscript?tab=files?
Andrea Giammarchi 27/03/2024 15:40
you need a fully qualified URL that can grab the .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)
Avatar
Jeff Glass 27/03/2024 15:54
If I'm thinking right @Andrea Giammarchi , and of the versions visible at the CDN link (under the files tab)https://www.jsdelivr.com/package/npm/@micropython/micropython-webassembly-pyscript?tab=files should "work", since that's where things started getting published when Damien started working on that port. Of course @chris.laffra, as you start using versions other than the pinned version in a specific PyScript release, compatibility as you go back in time isn't totally guaranteed, so test/explore at your own peril. But as Andrea says, that feature is useful for testing things against past MPy releases, or your own builds of MPy/CircuitPython/etc.
Avatar
chris.laffra 27/03/2024 15:57
@Jeff Glass Yeah, the goal is to pin things down and only upgrade to newer versions after doing testing.
15:57
It would be good to add this info to the docs about "interpreter"
Avatar
Avatar
chris.laffra
It would be good to add this info to the docs about "interpreter"
Andrea Giammarchi 27/03/2024 17:43
we don't really encourage pinning underlying versions of interpreters, as we inevitably change things around those interpreters as they change (Pyodide) or "grow up" and mature (MicroPython). If the surrounding code expects 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?
Avatar
Avatar
Andrea Giammarchi
we don't really encourage pinning underlying versions of interpreters, as we inevitably change things around those interpreters as they change (Pyodide) or "grow up" and mature (MicroPython). If the surrounding code expects 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?
chris.laffra 27/03/2024 18:50
I understand, but I am faced with MicroPython errors that I cannot debug in certain versions....
18:51
Absolutely no idea what API I call that is not implemented and worked before...
Avatar
@chris.laffra all feedback on improving error messages for debugging purposes most welcome. I have a call with Damien tomorrow (with Andrea) and we can raise this. 👍
Avatar
chris.laffra 27/03/2024 18:55
I was on a VERY old build, so switched to the latest MicroPython and things work again.
18:56
I have reported the "has not implemented" issue before. What is the right way, open a ticket somewhere?
Avatar
Hmm... where did you report the issue..? I'd mention it over on the MicroPython github.
19:00
Also, MicroPython has a discord server with a webassembly channel. Damien is active in there... https://discord.gg/jmyM2f99pA
Invite to join a server
Guild icon
webassembly
Avatar
Avatar
chris.laffra
I have reported the "has not implemented" issue before. What is the right way, open a ticket somewhere?
Andrea Giammarchi 27/03/2024 22:16
this is solved in latest, and it's known to be broken in not latest ... nothing you need to do, unless you encounter that with, or after, latest.
Avatar
Jeff Glass 27/03/2024 23:55
Ah yes, I would encourage you to pin PyScript versions, but not pin micropython separately in your applications. There is so much progress in both, essentially each PyScript release to a specific release of micropython (and Pyodide, but that API is a little older/more stable). PyScript makes zero guarantees about compatibility with previous or future MPy releases other than the one pinned in the release
Avatar
Jeff Glass 28/03/2024 00:02
(Chris I think you understand this all, I’m mostly spelling it out for posterity) (edited)
Avatar
Avatar
ntoll
@AndrewD 👋 I just tried @when with MicroPython, and it works for me (see: https://pyscript.com/@ntoll/floral-bush/latest). Can you supply more context please..? Thank you! 👍
The only two key differences I see are: 1) My button id has two '_' in the name: <button id="unit_barcode_lookup">Lookup</button> 2) my script is async and the handler is aync as it uses fetch() <script type="py" src="./main.py" async></script> main.py: @when("click", "#unit_barcode_lookup") async def unit_barcode(event): barcode = document.querySelector("#barcode").value response = await fetch(f"/unit?barcode={barcode}") The handler runs with <script type="py" ... /> but not <script type="mpy" ... /> In both py and mpy this works: display(f"innerText={document.querySelector('#unit_barcode_lookup').innerText}") This is displayed: innerText=Lookup (edited)
Avatar
Avatar
AndrewD
The only two key differences I see are: 1) My button id has two '_' in the name: <button id="unit_barcode_lookup">Lookup</button> 2) my script is async and the handler is aync as it uses fetch() <script type="py" src="./main.py" async></script> main.py: @when("click", "#unit_barcode_lookup") async def unit_barcode(event): barcode = document.querySelector("#barcode").value response = await fetch(f"/unit?barcode={barcode}") The handler runs with <script type="py" ... /> but not <script type="mpy" ... /> In both py and mpy this works: display(f"innerText={document.querySelector('#unit_barcode_lookup').innerText}") This is displayed: innerText=Lookup (edited)
@ntoll I just created a pyscript account and cloned your test and replicated the behaviour: 1) add async => event handler does not run with mpy See: https://pyscript.com/@andrew_vr_d/floral-bush-test/latest EDITED: I also noticed an slightly unexpected behaviour in pyscript.com: If you edit code and click "run", sometimes it doesn't seem to update or runs the old version? I'm not sure what happened, but when I first added async it seemed to work so I made more changes, but I got different results when I tried to reduce the test case. My first version of this message was incorrect because of this. I've apparently got used to vscode autosaving when you debug, in an interface like pyscript.com "what you see is what you run" is probably a worthwhile behavior? That, or warn if you run with unsaved changes? (edited)
Avatar
@AndrewD thanks for the feedback. @Andrea Giammarchi this "doesn't work with async in MicroPython" is interesting. I wonder if we're not awaiting awaitables in MicroPython..? Ideas welcome..!
Avatar
Avatar
ntoll
@AndrewD thanks for the feedback. @Andrea Giammarchi this "doesn't work with async in MicroPython" is interesting. I wonder if we're not awaiting awaitables in MicroPython..? Ideas welcome..!
Andrea Giammarchi 28/03/2024 09:04
the 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.
09:06
for later meeting, this is my clone https://pyscript.com/@agiammarchi/floral-bush-test-copy/latest the <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.
Avatar
Thanks for the info regarding the top level await, i am really just hacking around trying to see what works as I investigate pyscript. I hadn't used async io in python until it was required for trying pyscriot.fetch.
Avatar
Avatar
AndrewD
Thanks for the info regarding the top level await, i am really just hacking around trying to see what works as I investigate pyscript. I hadn't used async io in python until it was required for trying pyscriot.fetch.
Andrea Giammarchi 28/03/2024 14:44
it's not strictly required, you can still fetch(url).text().then(lambda result: do_your_thing(result))
Avatar
Avatar
Andrea Giammarchi
it's not strictly required, you can still fetch(url).text().then(lambda result: do_your_thing(result))
with pyscript.fetch()?
Avatar
Avatar
Dagusiu
I noted this line in the documentation: 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
I would like to raise this again. Does anyone know which reference the documentation is referring to? If no such reference exists, I think the documentation should be changed to reflect this.
Avatar
Avatar
AndrewD
with pyscript.fetch()?
Andrea Giammarchi 02/04/2024 09:03
yes, 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).
09:04
for any more convoluted use case, use response = await fetch(url);text = await response.text(); so you have full control too
Avatar
Avatar
Andrea Giammarchi
for any more convoluted use case, use response = await fetch(url);text = await response.text(); so you have full control too
My comment was related to .then() which seems more like JS? As least .then doesn't seem to be implemented hence my curiosity. But the interface as documented is great and does everything I need for my usage. I like the ability to have fine grained control. One detail: if the response is not ok (eg 404) the simple case didn't seem to throw with .json(), it just returned the error code as a detail field in json.
Avatar
Avatar
AndrewD
My comment was related to .then() which seems more like JS? As least .then doesn't seem to be implemented hence my curiosity. But the interface as documented is great and does everything I need for my usage. I like the ability to have fine grained control. One detail: if the response is not ok (eg 404) the simple case didn't seem to throw with .json(), it just returned the error code as a detail field in json.
Andrea Giammarchi 02/04/2024 12:25
any promise in JS has a 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 😅
Avatar
Avatar
AndrewD
My comment was related to .then() which seems more like JS? As least .then doesn't seem to be implemented hence my curiosity. But the interface as documented is great and does everything I need for my usage. I like the ability to have fine grained control. One detail: if the response is not ok (eg 404) the simple case didn't seem to throw with .json(), it just returned the error code as a detail field in json.
Andrea Giammarchi 02/04/2024 12:26
if the error populate the content of the request with valid json you get that indeed ... use the fine-grained version and deal with anything you like 👍
👍 1
Avatar
Avatar
Andrea Giammarchi
any promise in JS has a 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 😅
I really appreciate the feedback. I was just checking my interpretation was correct and hoping that this discussion helps with the docs.
Avatar
Hello! New to PyScript and just working through learning the configuration and all. My biggest question about the documentation is about User Guide > Configuration > Options > Files. This is very useful when I want to use a python module I wrote for a website that is in the development environment! Only complaint is that I currently have to copy every file (__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)
Avatar
Avatar
shupik
Hello! New to PyScript and just working through learning the configuration and all. My biggest question about the documentation is about User Guide > Configuration > Options > Files. This is very useful when I want to use a python module I wrote for a website that is in the development environment! Only complaint is that I currently have to copy every file (__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)
Jeff Glass 14/04/2024 02:21
In general there’s not, since the browser doesn’t have a way to enumerate the folders on your local filesystem and fetch them. If your local dev environment has configurability, PyScript will automatically unzip .zip and .tar.gz files - maybe a local tool that zips up all the files in your local directory ?
Avatar
Avatar
Jeff Glass
In general there’s not, since the browser doesn’t have a way to enumerate the folders on your local filesystem and fetch them. If your local dev environment has configurability, PyScript will automatically unzip .zip and .tar.gz files - maybe a local tool that zips up all the files in your local directory ?
I suspected the first bit, and lovely, thank you for such a quick answer! I can set that up in the build process. I might suggest adding something to the documentation part for the Packages warning.
If you need Python modules for MicroPython, use the files option to manually copy the source code onto the file system.
Maybe something that says copying over the source gar zip or tar gz
(edited)
Avatar
Avatar
shupik
I suspected the first bit, and lovely, thank you for such a quick answer! I can set that up in the build process. I might suggest adding something to the documentation part for the Packages warning.
If you need Python modules for MicroPython, use the files option to manually copy the source code onto the file system.
Maybe something that says copying over the source gar zip or tar gz
(edited)
Andrea Giammarchi 15/04/2024 08:50
IIRC @Jeff Glass also wrote how to publish your package form GitHub (or he surely did before) which might be another option so you host your files in there and the rest happens out of the box. This gives you semver or release tag guards too, otherwise the .zip solution should work in both Pyodide and MicroPython case.
👍 1
Avatar
@here next week (starting 22nd April) is "documentation week". Please feel free to add tickets to the repos here: https://github.com/pyscript/docs
Contribute to pyscript/docs development by creating an account on GitHub.
10:04
Let's help everyone access and learn PyScript with a whole bunch of documentation improvements. 👍 We'd love your input and participation too..! 🤗
Avatar
@here a huge rewrite of the docs can be found here: https://docs.pyscript.net/2024.5.1/ Some highlights:
  • Search! Search! Search!
  • Addressed lack of examples.
  • Complete pyscript.foo builtins.
  • Rewrite, corrections and remove duplications.
  • It was the best of times, it was the worst of times... 😉
❤️ 1
11:00
Still so much more to do.
11:02
Also, we tracked down the domain / CNAME bug in our infra, so the URL will always be docs.pyscript.net/blah ... That's a couple of hours of my life I'll never get back. Thanks to Anaconda infra colleagues for helping out there. 😉
🫡 1
🙏 1
Avatar
Hi, new to PyScript, I really appreciate the https://docs.pyscript.net/2024.6.2/user-guide/builtins/ page -- however I'm missing a page that lists all the modules (eg., js, pyscript, pyweb, pydom) that are injected into the the python module list. It would be nice with a reference list similar to the builtins page above. I understand that all/most are documented in a mostly unstructured way today, but the only way to find this is by searching the docs which isn't ideal (for me, and I assume others as well).
Avatar
👋 we're currently working on such a page, that will sit between the user-guide and FAQ in the left hand menu, entitled "Built-in APIs"
❤️ 2
Avatar
OK... @tth the new version of the docs as a "Built-in API" section at the top level that lists all the modules in the pyscript namespace.
Avatar
I noticed, it's very much what I needed/wanted :-)
17:00
One question, I'm not sure this is a documentation issue, may just be my lack of understanding of the underlying systems (pyodiode, polyscript, etc), but if PyScript is only injecting the name "pyscript" where does for instance "js" come from? I don't think that PyScript should repeat documentation that exist elsewhere, but a quick overview of the namespaces of all involved systems might be useful.
Avatar
@tth good point. The 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. 😉 But at the same time, we also like to keep PyScript nice and small for simplicity, size and maintainability reasons.
Avatar
I'm still very new to PyScript, so I'm sure this lack of overview will bother me less and less as I learn more of the platform's architecture :-)
Avatar
@tth just keep asking questions... we're happy to help, and since we don't have beginner's eyes in relation to the project (like you do), your feedback about this stuff is invaluable for us. In that way we're able to improve the docs for folks who are new to PyScript. 👍
Avatar
I'll keep that in mind -- but for now I think my biggest "problem" is that I just need to put in the work to become familiar with the system. My next learning exercise is to convert my existing javascript modules into 100% python. The code examples are a great help with that :-)
👍 1
Avatar
Andrea Giammarchi 12/09/2024 12:27
My next learning exercise is to convert my existing javascript modules into 100% python
just FYI we are perfectly capable of importing JS modules into Python and use these either from the main thread or the worker ... you don't need to migrate everything to start playing with PyScript, you can start building with it and port only things you believe should be ported.
Avatar
Trying to take an svg I have constructed in code and convert it to an image so I can draw it on a canvas. Is to_js() going to help me with this ? or do I need to do all the steps. (svg to a string, tostring, string to a blob, createobjurl of the blob with img mimetype, drawImage to the canvas). Any help for this process ?
Avatar
amphicoelias. 26/09/2024 08:58
A bit of example code on the section on the DOM in the User guide is: "my_div.classes.append("a-css-class")". This seems like a mistake to me. (At least it throws an error for me, since the Classes object does not have an append method.) It seems to me it should be "my_div.classes.add("a-css-class")"
Avatar
@amphicoelias. oooh... good catch. Thank you..!
Avatar
You're welcome. Thank you for finding the 🐛 🙂
Avatar
@ntoll in the help here: https://docs.pyscript.net/2024.9.1/user-guide/workers/ there is a link to a worker demo on your pyscript.com page but it is missing... Trying to find it - does it have a new location ?
Avatar
Where's the link? (And to what?)
Avatar
its close to "thread and the worker must be serializable"
👍 1
11:46
I'm thinking maybe the worker has to also be in the toml file under [files] ?
Avatar
Hi, is there some high-level documentation (for python beginners) to understand the following aspects of building an app with Pyscript + frameworks: 1) Persistent storage, 2) Login/authentication, 3) API, 4) Security, 5)Sharing? (edited)
Avatar
@patben well, there's https://docs.pyscript.net/2024.10.2/beginning-pyscript/ which gets you started. A beginner's tutorial is definitely on my radar... but it's item 3627384992384754 on my to do list. 😉 Happy to discuss / collaborate.
Avatar
@ntoll thank-you. I also found some answers in chatGPT. I am interested in better understanding pyscript limitations compared to traditional server-side architecture. And also if there is optimal hybrid architecture combining client and server sides.
Avatar
Yup, I hear ya. I have a similar interest too. Clearly "limitation" depends on context, and one person's limitation is another person's feature. PyScript is all about giving folks choices and, because we're still a relatively young project, discerning what idiomatic PyScript is. For example. @Chris Laffra has settled on a pattern where MicroPython is used to drive the UI while Pyodide (i.e. CPython) is used for more expensive computation on a web worker. As always, this is a work in progress and we'd love folks to tell us what's on their minds. 👍
👍 1
Avatar
Avatar
patben
@ntoll thank-you. I also found some answers in chatGPT. I am interested in better understanding pyscript limitations compared to traditional server-side architecture. And also if there is optimal hybrid architecture combining client and server sides.
Chris Laffra 18/11/2024 13:26
Interesting aspect of PyScript is that you can write a Python class once and then use it both on the server and in the browser. I have done this with PySheets and makes it a LOT easier and more reliable than having to marshall between Python on the server and JavaScript in the browser.
Avatar
Chris Laffra 18/11/2024 13:38
@patben When it comes to developing UIs, the PyScript project is still trying to figure out how to do it, I guess. One school of thought is to use traditional HTML+CSS and then write hooks for events using 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/).
Avatar
Avatar
Chris Laffra
Interesting aspect of PyScript is that you can write a Python class once and then use it both on the server and in the browser. I have done this with PySheets and makes it a LOT easier and more reliable than having to marshall between Python on the server and JavaScript in the browser.
Great concept indeed. I wasn't aware of that!
Avatar
Avatar
Chris Laffra
@patben When it comes to developing UIs, the PyScript project is still trying to figure out how to do it, I guess. One school of thought is to use traditional HTML+CSS and then write hooks for events using 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/).
ok and this is where it is difficult (for beginners) to make arbitrage. It would be nice to have more information about these options (blogs, tutorials, etc..). No pressure - but I do think it is valuable. Also I think the front-end part is also very interesting especially if it can stay fully pythonic. Congrats for LTK and Pysheets too. (edited)
👍 1
Avatar
@patben so we have a project called "Invent", that's currently in development (early days), targetting beginner coders who want to build Python driven UI based apps with PyScript.
👍 1
Avatar
;'/
12:39
]
12:41
[Sorry abt the noise - I was carrying a cup of tea and my computer ...]
Avatar
...almost a winky smiley. Nicely aimed. 🤣 🫖
Avatar
Andrea Giammarchi 19/11/2024 16:10
I feel like that cup felt on the floor now
Avatar
hi! are there any examples that use workers? the worker section of the docs seems to suggest that almost all pyscript apps should run in workers, saying things like "You should never block the main thread." in bold. But then it only links to one example, which is currently a 404: https://pyscript.com/@ntoll/tiny-silence/latest
09:49
i clicked on a whole bunch of the examples on https://pyscript.com/@examples, and haven't found one that uses workers yet
Avatar
@personman ouch... that example should be live. I'll try fixing in tomorrow (right now = end of my day).
Avatar
thanks!
Avatar
Avatar
ntoll
@personman ouch... that example should be live. I'll try fixing in tomorrow (right now = end of my day).
heya, just a gentle nudge in case this slipped your mind :)
Avatar
The Example applications page in the docs lists A simple clock as an example, but the link is 404
Avatar
Avatar
jburnett
The Example applications page in the docs lists A simple clock as an example, but the link is 404
Hi @jburnett, I noticed that as well when I was going through some of the examples. It looks @Neon22 was doing some amazing work fixing up the examples in this PR: https://github.com/pyscript/docs/pull/137
included new examples. Made notes about what packages are loaded and added complexity sub headings. Also note there are a number of errors in the examples. Note: Updated from 14 to 20 found at abo...
Avatar
Avatar
danyeaw
Hi @jburnett, I noticed that as well when I was going through some of the examples. It looks @Neon22 was doing some amazing work fixing up the examples in this PR: https://github.com/pyscript/docs/pull/137
They tell me they're working on it. Waiting for the holidays to end - shouldn't be too much longer. Some already fixed but not yet published - so can see them in the github but not on the site.
👍 1
Avatar
I still have some toml files with [[fetch]] in them but can't find it in the docs. Has it been replaced by [files] or can I just not find it
Avatar
Avatar
Neon22
I still have some toml files with [[fetch]] in them but can't find it in the docs. Has it been replaced by [files] or can I just not find it
PyScript is an open source platform for Python in the browser. Try PyScript: https://pyscript.com Examples: https://tinyurl.com/pyscript-examples Community: https://discord.gg/HxvBtukrg2 - pyscri...
Avatar
Avatar
danyeaw
@Andrea Giammarchi @ntoll can we get an official position on this [[fetch]] please ?
Avatar
Avatar
Neon22
@Andrea Giammarchi @ntoll can we get an official position on this [[fetch]] please ?
Andrea Giammarchi 11/02/2025 09:06
I believe that's legacy logic we still wanted to support but indeed we suggest using [files] these days.
Avatar
Thanks. I'll update my examples
Avatar
@Neon22 it's a legacy thing hiding in plain sight so we didn't break all the things. However, you should use [files] from now on, and perhaps we should remove support for [[fetch]]..? Thoughts in the community call perhaps..?
Avatar
Does [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"
Avatar
Does it work if you lose the RHS of the equals ? I think you only need both sides if you're changing the name/path
Avatar
I tried that as well with "/card_dectector.py" = "", same issue.
Avatar
Hmm... @danyeaw this is interesting. TL;DR don't use 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!
Avatar
Avatar
danyeaw
I tried that as well with "/card_dectector.py" = "", same issue.
This should work (I think) [files] "./card_detector.py" = ""
Avatar
@danyeaw I think the initial "./" is important or "" but not "/"
Avatar
@Neon22 of course... the left hand side is a URL (either a fully qualified one, or a relative one).
Avatar
Yup, that fixes it - great catch! I'll submit a PR to update the docs since the examples show "/code.py" = "./subdir/code.py" which is clearly wrong 😄
Avatar
Sorry... that'll be my fault. Glad you caught it. 👍
Avatar
Avatar
Neon22
@danyeaw I think the initial "./" is important or "" but not "/"
Andrea Giammarchi 12/02/2025 16:55
it's all about relative VS absolute URLs after all, that was a great hint 🙏 (edited)
Avatar
I checked the official examples and all ref to [[fetch]] has gone. but no examples yet using 'new' files mechanism of (say) loading a local image to show as a banner. I'm making some examples to submit.
❤️ 1
🎉 1
Avatar
__ export __ = […] in module seems working only when made with <script> but not with PyWorker, if thats the case its good to be mentioned so in the documentation. (edited)
👍 1
Avatar
This is perhaps a bug? Feel free to report it! 🙏
👌 1
Avatar
Avatar
Ridensium
__ export __ = […] in module seems working only when made with <script> but not with PyWorker, if thats the case its good to be mentioned so in the documentation. (edited)
Andrea Giammarchi 11/03/2025 16:41
what do you mean? any live example we canb check?
Avatar
Avatar
Andrea Giammarchi
what do you mean? any live example we canb check?
Avatar
Andrea Giammarchi 11/03/2025 17:13
well ... 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.
17:14
we don't state anywhere this is also true for PyWorker:
The pyscript.workers reference allows Python code in the main thread to easily access named workers (and their exported functionality).
Avatar
Avatar
Andrea Giammarchi
well ... 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.
thats why i mentioned it here as to have some hint in the documentation as it is not a bug (edited)
Avatar
Andrea Giammarchi 11/03/2025 17:16
I'd say this would be a feature request but if the docs don't state utilities are exported out of the box, I am not sure we should add that expectation or just keep things as these are right now. Any use case for not having a named worker instead? Runtime worker file might be one but I think you can always use a named worker to orchestrate whatever you like.
👌 1
17:17
anyway, off for today ... feel free to open either an issue or a discussion around this, thank you!
Avatar
Eruvanos [UTC+1] 28/05/2025 11:12
Hi, where could I find the docs about pydom? The link in the docs seem to lead into the void: https://docs.pyscript.net/2025.5.1/user-guide/dom/#pydom
Avatar
Avatar
Eruvanos [UTC+1]
Hi, where could I find the docs about pydom? The link in the docs seem to lead into the void: https://docs.pyscript.net/2025.5.1/user-guide/dom/#pydom
I think you're looking for this https://docs.pyscript.net/2025.3.1/user-guide/dom/ its all under pyscript.web now. I believe docs are being updated. Consider using the ltk for anything more complex. https://pyscript.github.io/ltk/?tab=2&runtime=mpy
Avatar
Avatar
Neon22
I think you're looking for this https://docs.pyscript.net/2025.3.1/user-guide/dom/ its all under pyscript.web now. I believe docs are being updated. Consider using the ltk for anything more complex. https://pyscript.github.io/ltk/?tab=2&runtime=mpy
Eruvanos [UTC+1] 01/10/2025 22:46
Any idea if it is planned to update the docs? I come back to the project from time to time, and give it another try. I know documentation is hard :/ Things I struggled with: create some function which fetches some data and shows it on the screen as soon as the page is ready. (that is often my first use case)
  • Maybe I oversaw it but a autogenerated api documentation based on the doc strings might be a good thing with lower maintenance.
Hope this message is not received in a bad matter, I wanted to provide some feedback regarding the docs. Despite that, the Python Arcade and Pyglet team still continues to bring Pyglet and Arcade into the browser. we already have some playgrounds here: https://pyscript.com/@eruvanos/pyglet-web/latest?files=README.md https://pyscript.com/@eruvanos/arcade-web/latest?files=main.py (Still some rendering issues, but the major work is already done) Thanks for your great work
Avatar
Eruvanos [UTC+1] 02/10/2025 08:14
I opened a PR for the first point: https://github.com/pyscript/docs/pull/193
❤️ 1
Avatar
Avatar
Eruvanos [UTC+1]
Any idea if it is planned to update the docs? I come back to the project from time to time, and give it another try. I know documentation is hard :/ Things I struggled with: create some function which fetches some data and shows it on the screen as soon as the page is ready. (that is often my first use case)
  • Maybe I oversaw it but a autogenerated api documentation based on the doc strings might be a good thing with lower maintenance.
Hope this message is not received in a bad matter, I wanted to provide some feedback regarding the docs. Despite that, the Python Arcade and Pyglet team still continues to bring Pyglet and Arcade into the browser. we already have some playgrounds here: https://pyscript.com/@eruvanos/pyglet-web/latest?files=README.md https://pyscript.com/@eruvanos/arcade-web/latest?files=main.py (Still some rendering issues, but the major work is already done) Thanks for your great work
wow - great job with pyglet. I'd seen they had a webgl backend but hadn't got around to trying it out. very nice - move over pygame 🙂
Avatar
@Eruvanos [UTC+1] thanks for all the feedback! We're currently planning our next blocks of work and the docs are front-and-centre of this, so expect movement over the coming weeks.
🎉 1
🙏 1
Avatar
Original message was deleted or could not be loaded.
Does spam like this actually work? I doubt you'll find any success here.
Exported 217 message(s)
Timezone: UTC+0