'Initializes on an OGR C pointer to the Layer and the `DataSource` object
that owns this layer.  The `DataSource` object is required so that a
reference to it is kept with this Layer.  This prevents garbage
collection of the `DataSource` while this Layer is still active.'

def __init__(self, layer_ptr, ds):

    if (not layer_ptr):
        raise OGRException('Cannot    create    Layer,    invalid    pointer    given')
    self.ptr = layer_ptr
    self._ds = ds
    self._ldefn = capi.get_layer_defn(self._ptr)
    self._random_read = self.test_capability('RandomRead')
