In chapter 2, on the code example of "Special Attributes, Methods and
Operators", we have

class MyList(object)
     def __init__(self, *a): self.a = a
     def __len__(self): return len(self.a)
     def __getitem__(self, i): return self.a[i]
     def __setitem__(self, i, j): self.a[i] = j
b = MyList(3, 4, 5)
print b[1]
a[1] = 7
print b.a

1. The first line should be
class MyList(object):

2. Running line 9 of the code produces this exception:
>>> a[1] = 7
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined

I'm not sure what was intended to be demonstrated there, as even b[1]
= 7 produces an excption, but it's not working.

Reply via email to