So far we've been working with functions and packages of functions, as well as defining our own functions. It turns out, though, that we've been working with objects all along, we just haven't recognize them as such. For example,
The choice of function or "message" is up to the library designer, but `lower` only makes sense for strings so it makes sense to group it with the definition of `str`.
In terms of implementation, however, `x.lower()` is actually implemented as `str.lower(x)` where `str` is the class definition for strings. Computer processors understand function calls; they do not understand objects and so we performed this translation within the Python interpreter itself.
# Package vs object members
Let's get another thing straight. The dot `.` operator is overloaded in Python to mean both package member and object member access. You are familiar with this already:
This is a common point of confusion when reading code. When we see `a.f()`, we don't know whether that function `f` is a member of the package identified by `a` or an object referred to by `a`.
In the wordsim project, you defined a file called `wordsim.py` and then my `test_wordsim.py` file did `from wordsim import *` to pull in all your functions in `wordsim.py`.
## Exercise
In the following, identify the *identifiers* (words) as package or function or field:
在下文中,将*标识符*(单词)标识为包或函数或字段:
1.`np.log(3)`
1.`np.linalg.norm(v)`
...
...
@@ -133,7 +95,7 @@ In the following, identify the *identifiers* (words) as package or function or f
1.`np.pi`
1.`img = img.convert("L")`
Now, identify the data types of subexpressions and identify the *identifiers* (words) as package or function or field: