MCPcopy Create free account
hub / github.com/ipython/ipython / hasattr

Method hasattr

IPython/utils/ipstruct.py:247–263  ·  view source on GitHub ↗

hasattr function available as a method. Implemented like has_key. Examples -------- >>> s = Struct(a=10) >>> s.hasattr('a') True >>> s.hasattr('b') False >>> s.hasattr('get') False

(self, key)

Source from the content-addressed store, hash-verified

245 return Struct(dict.copy(self))
246
247 def hasattr(self, key):
248 """hasattr function available as a method.
249
250 Implemented like has_key.
251
252 Examples
253 --------
254
255 >>> s = Struct(a=10)
256 >>> s.hasattr('a')
257 True
258 >>> s.hasattr('b')
259 False
260 >>> s.hasattr('get')
261 False
262 """
263 return key in self
264
265 def allow_new_attr(self, allow = True):
266 """Set whether new attributes can be created in this Struct.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected