Recognizing bare naked functions

REMEMBER Most function/method calls have self or a module name in front of them, followed by a dot. When you're reading a program, if you see a bare function or method (or class)—one without self or a module name—it usually means one of these:

• It was defined in the module (like get_page() and find_links() are in this program).

• It was imported by using the from... import syntax (like

StringIO).

• It is a built-in function (like sorted(), down at the bottom). REMEMBER Functions and methods are essentially the same thing—a code block that performs an action and returns a result. Here's the difference:

• A function is by itself in a module.

Chapters 3, 11, and 13 describe how to use functions, methods, and classes.

Was this article helpful?

0 0

Post a comment