

Now what if you import mod again inside the same session?Ġ1:19 Nothing happens. Initially as it imported mod, it went ahead and did the print() statement inside there using the f-string, and inside here mod.a is available. Okay, down here in the terminal, what happens if I start the REPL and import mod?Ġ1:06 Well, you can see it here.
.jpg)
In fact, modify it a little bit and use an f-string.Ġ0:52 And that can show that every time that this module is imported, it would print this out, right? So, save this extra line. Just keep a simple print() statement for printing a out. That’s usually okay.Ġ0:33 Let me have you take a look at that.Ġ0:36 Go ahead and reopen mod.py, and inside of it I’m going to have you go ahead and clear out this if _name_ = '_main_'.

Usually the executable statements are only for initialization, and it makes sense that these statements will only be executed the first time a module is imported. Even if you were to try, a module is only loaded once per interpreter session, and that’s going to work fine for functions and class definitions and importing all those objects initially.Ġ0:17 But sometimes modules can contain executable statements as well. Up to now, you’ve been simply importing a module once. 00:00 In this video, I’ll show you about reloading a module.
