That example code you link to looks like it's out of date (for an old version of pyshp).
This works (based on bits and pieces from the docs):
shp = r"path/to/shp" # NOTE no .shp extension
import os.path
from shapefile import (Reader, Writer)
try: # Py2 (I haven't actually tested on python 2...)
from StringIO import StringIO as IO
except ImportError: # Py3
from io import BytesIO as IO
with IO() as shpio, IO() as dbfio: # Don't overwrite existing .shp, .dbf
with Reader(shp) as r, Writer(shp=shpio, dbf=dbfio, shx=os.path.splitext(shp)[0]+'shx=shp+'.shx') as w:
w.fields = r.fields[1:] # skip first deletion field
for rec in r.iterShapeRecords():
w.record(*rec.record)
w.shape(rec.shape)