problem in "self"

i try to execute this code :
from paraview.simple import *
from paraview import vtk
reader = OpenDataFile(’/home/ikram/Bureau/C0002.vtk’)

pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()
numPoints = pdi.GetNumberOfPoints()
pdo.Allocate()
for i in range(0, numPoints-1):
points = [i, i+1]
# VTK_LINE is 3
pdo.InsertNextCell(3, 2, points)

Show(reader)

but it bugs :
NameError: name ‘self’ is not defined

how can i fix it