This is a patch suggested in #473912 (i.e. fix for upstream bug #2187). 
It is merged in 1.5.2 AFAIK.

diff -urNad gdal-1.5.1~/swig/python/osgeo/ogr.py gdal-1.5.1/swig/python/osgeo/ogr.py
--- gdal-1.5.1~/swig/python/osgeo/ogr.py	2008-04-19 19:46:19.000000000 +0200
+++ gdal-1.5.1/swig/python/osgeo/ogr.py	2008-05-06 16:50:37.000000000 +0200
@@ -6,6 +6,8 @@
 
 import _ogr
 import new
+import types
+
 new_instancemethod = new.instancemethod
 try:
     _swig_property = property
@@ -38,14 +40,12 @@
     except: strthis = ""
     return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
 
-import types
 try:
     _object = types.ObjectType
     _newclass = 1
 except AttributeError:
     class _object : pass
     _newclass = 0
-del types
 
 
 wkb25Bit = _ogr.wkb25Bit
@@ -561,7 +561,6 @@
     ] would return the first layer on the datasource.
     aname'] would return the layer named "aname".
     :4] would return a list of the first four layers."""
-        import types
         if isinstance(value, types.SliceType):
             output = []
             for i in xrange(value.start,value.stop,value.step):
@@ -581,7 +580,6 @@
 
     def GetLayer(self,iLayer=0):
         """Return the layer given an index or a name"""
-        import types
         if isinstance(iLayer, types.StringTypes):
             return self.GetLayerByName(str(iLayer))
         elif isinstance(iLayer, types.IntType):
@@ -1829,7 +1827,6 @@
             raise AttributeError, name
 
     def GetField(self, fld_index):
-        import types
         if isinstance(fld_index, types.StringType):
             fld_index = self.GetFieldIndex(fld_index)
         if (fld_index < 0) or (fld_index > self.GetFieldCount()):
