![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
This package provides a decorator for hot-reloading python functions.
It allows to redefine the function in the source code and see the changes immediately without restarting the program.
Install with pip
$ python -m pip install hotfunc
The following example uses the REPL, but hotfunc
can be used in any python program.
Begin with importing the module and decorating the function that you want to hot-reload.
# myfile.py
from hotfunc import hotreload
name = "Mike"
@hotreload
def say():
print(f"Hello world! My name is {name}.")
Start python REPL, import the source file and call your function.
>>> from myfile import say
>>> say()
Hello world! My name is Mike.
Now, without stopping the interpreter, edit the source file changing the decorated function's body.
# myfile.py
from hotfunc import hotreload
name = "Mike"
@hotreload
def say():
print(f"Ciao mondo! Mi chiamo {name}.")
Switch back to REPL and call the function again.
>>> say()
Ciao mondo! Mi chiamo Mike.
As you can see, the function has been redefined, but its local environment (name
variable defined outside the function) was preserved.
When hot-reloading a function, its source file is read, definition found and the function itself redefined. Currenty it is done on every call, so is rather slow.
As of now, only top-level functions (defined at indentation level zero) are supported.
By default, exceptions raised when redefining or calling hot-reloaded functions are not re-raised. Instead, they are printed to stdout
and the result of last successful function call is returned. This behaviour can be changed by enabling reraise
flag:
@hotreload(reraise=True)
def myfunc():
# ...
Copyright (c) 2023 Michał Szajbe
Licensed under The MIT License.
FAQs
Make functions hot-reloadable with a decorator
We found that hotfunc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.