Your code is growing in size and complexity. As that happens you need better ways to abstract, to modularize, to organize your code. You’ve seen that functions can be used to group lines of code together into bundles you can reuse over and over. And you’ve also seen that collections of functions and variables can be placed into modules so that they can be more easily shared and reused. In this chaper we’ll revisit modules and learn how to use them even more effectively (so you’re all ready to share your code with others) and then we’re going to look at the ultimate in code reuse: objects. You’re going to see that Python objects are all around you, just waiting to be used.
Greg: That’s easy; just ship him analyze.py. He can just import it and call the
compute_readability function. Done!
Frank: Totally. Modules are just Python files; just ship it.
Joe: I don’t think that is quite right. I know we’ve said a file is just a module and all that, and we’ve certainly used
import, but I think there is more to it than that.
Greg: Like what?
Joe: Well, for instance, right now, if you’ll remember, ...