Skip to content
Discussion options

You must be logged in to vote

@bonne-soeur

Some other people propose to "import" the script as it would be a library. Then , as a feature of python library, any code outside any function declaration will be executed at load time, ONCE. Re-importing will not do any thing!

To "reload" / be able to run it again at REPL/WebREPL:

>>> import toto
....
>>> import sys
>>> del(sys.modules['toto'])
>>> import toto
....

import will check sys.modules dict and if toto is there it won't load it, so basically just delete it from there and it can be imported again 👍🏼 .

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@bonne-soeur
Comment options

@bonne-soeur
Comment options

Answer selected by robert-hh
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jimmo
Comment options

jimmo Dec 5, 2022
Maintainer

@bonne-soeur
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants