Item 18: Class and dict attribute

class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
class GoodPoint(object):
    __slots__ = ('x', 'y')
    def __init__(self, x, y):
        self.x = x
        self.y = y

for point_type in (Point, GoodPoint):
    print('----', point_type)
    p = point_type(1, 2)
    try:
        p.z = 3
    except AttributeError as e:
        print('Caught:', repr(e))
    try:
        print(p.__dict__)
    except AttributeError as e:
        print('Caught:', repr(e))