@@ -277,9 +277,11 @@ inspect(10, methods=True)
277
277
278
278
In fact there are still more methods, as you can see if you execute ` inspect(10, all=True) ` .
279
279
280
+
281
+
280
282
## A Little Mystery
281
283
282
- In this lecture we claimed that Python is object oriented.
284
+ In this lecture we claimed that Python is, at heart, an object oriented language .
283
285
284
286
But here's an example that looks more procedural.
285
287
@@ -289,13 +291,12 @@ m = len(x)
289
291
m
290
292
```
291
293
292
- If Python is object oriented, why don't we use ` x.len() ` ? Isn't this
293
- inconsistent?
294
+ If Python is object oriented, why don't we use ` x.len() ` ?
294
295
295
- The answers are related to the fact that Python aims for consistent style.
296
+ The answer is related to the fact that Python aims for readability and consistent style.
296
297
297
298
In Python, it is common for users to build custom objects --- we discuss how to
298
- do this [ later] ( python_oop ) `.
299
+ do this {doc} ` later < python_oop> ` .
299
300
300
301
It's quite common for users to add methods to their that measure the length of
301
302
the object, suitably defined.
@@ -305,10 +306,10 @@ When naming such a method, natural choices are `len()` and `length()`.
305
306
If some users choose ` len() ` and others choose ` length() ` , then the style will
306
307
be inconsistent and harder to remember.
307
308
308
- To avoid this, the creator of Python chose to have some built-in functions
309
- like ` len() ` , to make clear that ` len() ` is the convention.
309
+ To avoid this, the creator of Python chose to add
310
+ ` len() ` as a built-in function , to help emphasize that ` len() ` is the convention.
310
311
311
- Now, having said all of this, Python still is object oriented under the hood.
312
+ Now, having said all of this, Python * is * still object oriented under the hood.
312
313
313
314
In fact, the list ` x ` discussed above has a method called ` __len__() ` .
314
315
@@ -341,7 +342,8 @@ This includes not just lists, strings, etc., but also less obvious things, such
341
342
* files opened for reading or writing
342
343
* integers, etc.
343
344
344
-
345
+ Remember that everything is an object will help you interact with your programs
346
+ and write clear Pythonic code.
345
347
346
348
## Exercises
347
349
0 commit comments