sgillies/shapely — Issue #21: Allow slices from coords
Author: mwtoews
Created: 2012-01-13 21:59:30+00:00
State: open

For example:

>>> from shapely.geometry import LineString
>>> line = LineString([(0,0),(1,1),(2,2)])
>>> line.coords[1] # works
>>> line.coords[1:] # doesn't work
Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\Lib\site-packages\shapely\coords.py", line 68, in __getitem__
if i + M < 0 or i >= M:
TypeError: unsupported operand type(s) for +: 'slice' and 'long'

See implementation of [`__getitem__` in coords.py](https://github.com/sgillies/shapely/blob/master/shapely/coords.py#L65)

According to the [documentation for `object.__getitem__(self, key)`](http://docs.python.org/reference/datamodel.html#object.__getitem__), `key` should be either an integer or slice object. Currently, it is implemented only as an integer.