Menu

Post image 1
Post image 2
1 / 2
0

Day-2 of learning Python | Exploring Python Shell and Module Reloading

DEV Community·Samiksha Srivastav·about 1 month ago
#yefWaW2s
Reading 0:00
15s threshold

While learning python today, I spent some time understanding how the Python shell works and how modules behave inside it. The Python shell (or REPL) is basically an interactive environment where you can run code line-by-line. It's super useful when you just want to test something quickly instead of running a full script every time. While experimenting, I tried something interesting. I created a Python file, defined a few functions and variables in it, and then imported that file into the Python shell. everything worked perfectly at first. But then I made some changes in the file - added few functions and modified a few existing ones - and tried to use them again in the shell. Surprisingly, I started getting errors. At first, it felt confusing because I had clearly updated the code. But then I learned what was actually happening behind the scenes. When we import a module in Python, it gets loaded into the memory once.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More