Opened 16 years ago

Closed 16 years ago

#2261 closed defect (duplicate)

python NameError getting features from layer using layer[0]

Reported by: steko Owned by: hobu
Priority: normal Milestone:
Component: PythonBindings Version: 1.5.0
Severity: normal Keywords:
Cc:

Description

I can't find the piece of news where I first learnt the existance of such a feature, so I'm not even sure this functionality actually exists (but the source of ogr.py confirms that it's there).

>>> from osgeo.ogr import *
>>> a = Open("pleiades.gml")
>>> layer = a[0]
>>> feature = layer[0]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/steko/bin/kml2shp/pleiades/<ipython console> in <module>()

/usr/lib/python2.5/site-packages/osgeo/ogr.py in __getitem__(self, value)
   1212     r[0] would return the first feature on the layer.
   1213     r[0:4] would return a list of the first four features."""
-> 1214         if isinstance(value, types.SliceType):
   1215             output = []
   1216             if value.stop == sys.maxint:

NameError: global name 'types' is not defined

This happens both with Python 2.4 and 2.5 on Debian Unstable, no matter which datasource I'm using.

Change History (1)

comment:1 by hobu, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate. Fixed in #2187

Note: See TracTickets for help on using tickets.