explicit$_{self.var}$ solves this nicely. Similarly, for using instance variables, having to write$_{self.var}$ means that references to unqualified names inside a method don’t have to search the instance’s directories. To put it another way, local variables and instance variables live in two different namespaces, and you need to tell Python which namespace to use. 

## 3.6 Why can’t I use an assignment in an expression? 

Starting in Python 3.8, you can! 

Assignment expressions using the walrus operator := assign a variable in an expression: 

while chunk :=fp.read(200 ): print(chunk) 

See PEP 572 for more information. 

## 3.7 Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))? 

As Guido said: 

(a) For some operations, prefix notation just reads better than postfix – prefix (and infix!) operations have a long tradition in mathematics which likes notations where the visuals help the mathematician thinking about a problem. Compare the easy with which we rewrite a formula like x*(a+b) into x*a + x*b to the clumsiness of doing the same thing using a raw OO notation. 

(b) When I read code that says len(x) I know that it is asking for the length of something. This tells me two things: the result is an integer, and the argument is some kind of container. To the contrary, when I read x.len(), I have to already know that x is some kind of container implementing an interface or inheriting from a class that has a standard len(). Witness the confusion we occasionally have when a class that is not implementing a mapping has a get() or keys() method, or something that isn’t a file has a write() method. 

—https://mail.python.org/pipermail/python-3000/2006-November/004643.html 

## 3.8 Why is join() a string method instead of a list or tuple method? 

Strings became much more like other standard types starting in Python 1.6, when methods were added which give the same functionality that has always been available using the functions of the string module. Most of these new methods have been widely accepted, but the one which appears to make some programmers feel uncomfortable is: 

",".join(['1','2','4','8','16 ']) 

which gives the result: 

"1, 2, 4, 8, 16 " 

There are two common arguments against this usage. 

The first runs along the lines of: “It looks really ugly using a method of a string literal (string constant)”, to which the answer is that it might, but a string literal is just a fixed value. If the methods are to be allowed on names bound to strings there is no logical reason to make them unavailable on literals. 

The second objection is typically cast as: “I am really telling a sequence to join its members together with a string constant”. Sadly, you aren’t. For some reason there seems to be much less difficulty with having$_{split()}$ as a string method, since in that case it is easy to see that 

