Page 244 - Beginning Programming with Pyth - John Paul Mueller
P. 244
source code directory after you import BPPD_11_Packages for the first time, you see the new __pycache__ directory. If you want to make changes to your package, you must delete this directory. Otherwise, Python will continue to use the unchanged cache file instead of your updated source code file.
The cached filename includes the version of Python for which it is meant, so it's BPPD_11_Packages.cpython-36.pyc in this case. The 36 in the filename means that this file is Python 3.6 specific. A .pyc file represents a compiled Python file, which is used to improve application speed.
4. Type dir(BPPD_11_Packages) and click Run Cell.
You see a listing of the package contents, which includes the SayHello() and SayGoodbye() functions, as shown in Figure 11-3. (A discussion of the other entries appears in the “Viewing the Package Content” section, later in this chapter.)
5. In a new cell, type BPPD_11_Packages.SayHello(“Josh”).
Notice that you must precede the attribute name, which is the SayHello() function in this case, with the package name, which is BPPD_11_Packages. The two elements are separated by a period. Every call to a package that you import follows the same pattern.
6. Type BPPD_11_Packages.SayGoodbye(“Sally”) and click Run Cell.
The SayHello() and SayGoodbye() functions output the expected text, as shown in Figure 11-4.