0

import and reload problem python

I learned the basics of Python with other resources and then decided to read Mark Lutz's book. At the second task I was asked to import file with simple code by example:  » from imp import reload  » reload(script1)  *some code*  »  And yes, I know that there's importlib instead of imp (they didn't change it to 5th edition). I actually tried to write this in different combinations but still nothing. When I do as it probably should be it goes:  »from importlib import reload  »reload(script1)  Traceback (most recent call last):  File "<pyshell#1>", line 1, in <module>  reload(script1)  NameError: name 'script1' is not defined  I've read that it can have to do something with where the file is saved but I did it with different files even in a folder where Python IDLE and other stuff are downloaded. There's no problem with code itself.  I most likely don't see the answer under my nose so I would like to ask you to help me

14th Aug 2019, 11:22 AM
Nyanyanya Anyanyaev
Nyanyanya Anyanyaev - avatar
3 Antworten
0
Do you have a script named "script1"
14th Aug 2019, 11:27 AM
Dlite
Dlite - avatar
0
No, script1 definitely exists I even rewrote it and put copies in different folders. And yes, I reloaded IDLE after changing the file.
14th Aug 2019, 11:49 AM
Nyanyanya Anyanyaev
Nyanyanya Anyanyaev - avatar