June 2017
Beginner
352 pages
8h 39m
English
Our module can also be imported into the REPL. Let's try that and see what happens. Start the REPL and import your module. When importing a module, you use import <module-name>, omitting the .py extension from the module name. In our case, it looks something like this:
$ pythonPython 3.5.0 (default, Nov 3 2015, 13:17:02)[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import wordsItwasthebestoftimes. . .
The code in your module is executed immediately when imported! That's maybe not what you expected, and it's certainly not very useful. To give us more control over when our code is executed, and to allow it to be reused, ...
Read now
Unlock full access