diff --git a/shapefile.py b/shapefile.py index f57ef31..d19610c 100644 --- a/shapefile.py +++ b/shapefile.py @@ -15,6 +15,7 @@ import time import array import tempfile +import itertools # # Constants for shape types @@ -552,6 +553,13 @@ def shapeRecords(self): return [_ShapeRecord(shape=rec[0], record=rec[1]) \ for rec in zip(self.shapes(), self.records())] + def iterShapeRecords(self): + """Returns a generator of combination geometry/attribute records for + all records in a shapefile.""" + for shape, record in itertools.izip(self.iterShapes(), self.iterRecords()): + yield _ShapeRecord(shape=shape, record=record) + + class Writer: """Provides write support for ESRI Shapefiles.""" def __init__(self, shapeType=None):