Comments (5)
This isn't a bug in Pyodide because you'll get the same behavior in native Python.
from pyodide.
Yup, and just to help the noobie the solution is to use the following method to delete it from the cache between saves:
import sys
del sys.modules['mymodule']
so the full solution would be:
import importlib
from pathlib import Path
import time
import sys
del sys.modules['mymodule']
Path("mymodule.py").write_text("""\
def hello():
print("hello world!")
"""
)
# importlib.invalidate_caches() # Make sure Python notices the new .py file
from mymodule import hello
hello()
del sys.modules['mymodule']
with open("mymodule.py", "w") as f:
f.write("""\
def hello():
print("hola mundo!")
""" )
# importlib.invalidate_caches()
from mymodule import hello
hello() # <-- ๐บ yea baby! "hola mundo!"
from pyodide.
It's hit or miss for me whether del sys.modukes['mymodule']
works. Which is strange. A bunch of other people report it working for them, but when I tried the code with del sys.modukes['mymodule']
I saw hello world
twice. Otherwise I would have suggested it. No idea why other people see it working but I don't...
from pyodide.
Thatโs not good ;( I will have to test it thoroughly then :/
from pyodide.
I just tried your code out both in Pyodide and with native Python 3.11 on linux and both ways it worked the way you say it should. So hopefully I just messed up something silly when I tried it before.
from pyodide.
Related Issues (20)
- Add `PyMuPDF` package
- runPython return missing
- cmake -E capabilities is broken HOT 1
- Release 0.26.0 HOT 5
- datasets (huggingface) HOT 6
- Cannot create a WebGL2 context when using SDL HOT 3
- request to add pandasai HOT 1
- request to add llama-index
- request to add langchain HOT 1
- request to add Boto3 HOT 4
- fastobo
- loadPackage() not to access the file system if the cache already exists HOT 2
- cvxpy-base 1.4.3 HOT 2
- html5_canvas_backend no longer works. HOT 1
- RFC Package unvendored stdlibs to sdist / wheel? HOT 3
- `make` in docker container `pyodide/pyodide-env` fails with `could not create work tree dir 'emsdk'` HOT 8
- DOM types in pyodide lead to build issues with Angular and typescript. HOT 3
- Request add to section-properies package
- feat: Resolving CORS Restrictions in Node.js HOT 2
- please make it work like normal python HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyodide.