MCPcopy
hub / github.com/django/django / __getitem__

Method __getitem__

django/contrib/gis/gdal/feature.py:31–46  ·  view source on GitHub ↗

Get the Field object at the specified index, which may be either an integer or the Field's string label. Note that the Field object is not the field's _value_ -- use the `get` method instead to retrieve the value (e.g. an integer) instead of a Field instance.

(self, index)

Source from the content-addressed store, hash-verified

29 self._layer = layer
30
31 def __getitem__(self, index):
32 """
33 Get the Field object at the specified index, which may be either
34 an integer or the Field's string label. Note that the Field object
35 is not the field's _value_ -- use the `get` method instead to
36 retrieve the value (e.g. an integer) instead of a Field instance.
37 """
38 if isinstance(index, str):
39 i = self.index(index)
40 elif 0 <= index < self.num_fields:
41 i = index
42 else:
43 raise IndexError(
44 "Index out of range when accessing field in a feature: %s." % index
45 )
46 return Field(self, i)
47
48 def __len__(self):
49 "Return the count of fields in this feature."

Callers

nothing calls this directly

Calls 2

indexMethod · 0.95
FieldClass · 0.90

Tested by

no test coverage detected