MCPcopy Create free account
hub / github.com/PyTables/PyTables / __getitem__

Method __getitem__

tables/misc/enum.py:160–185  ·  view source on GitHub ↗

Get the concrete value of the enumerated value with that name. The name of the enumerated value must be a string. If there is no value with that name in the enumeration, a KeyError is raised. Examples -------- Let ``enum`` be an enumerated type defined as:

(self, name: str)

Source from the content-addressed store, hash-verified

158 self.__dict__[name] = value
159
160 def __getitem__(self, name: str) -> Any:
161 """Get the concrete value of the enumerated value with that name.
162
163 The name of the enumerated value must be a string. If there is no value
164 with that name in the enumeration, a KeyError is raised.
165
166 Examples
167 --------
168 Let ``enum`` be an enumerated type defined as:
169
170 >>> enum = Enum({'T0': 0, 'T1': 2, 'T2': 5})
171
172 then:
173
174 >>> enum['T1']
175 2
176 >>> enum['foo']
177 Traceback (most recent call last):
178 ...
179 KeyError: "no enumerated value with that name: 'foo'"
180
181 """
182 try:
183 return self._names[name]
184 except KeyError:
185 raise KeyError(f"no enumerated value with that name: {name!r}")
186
187 def __setitem__(self, name: Any, value: Any) -> NoReturn:
188 """Forbidden operation."""

Callers 6

test04_getitemEArrayMethod · 0.45
test05_setitemEArrayMethod · 0.45
get_sliced_vars2Function · 0.45
test01_maindimMethod · 0.45
test02_getitemCArrayMethod · 0.45
test03_setitemCArrayMethod · 0.45

Calls

no outgoing calls

Tested by 6

test04_getitemEArrayMethod · 0.36
test05_setitemEArrayMethod · 0.36
get_sliced_vars2Function · 0.36
test01_maindimMethod · 0.36
test02_getitemCArrayMethod · 0.36
test03_setitemCArrayMethod · 0.36