class documentation

class Instance(BaseInstance): (source)

Known subclasses: astroid.nodes.Const, astroid.nodes.Dict, astroid.nodes.node_classes.BaseContainer, astroid.objects.DictInstance, astroid.objects.ExceptionInstance

View In Hierarchy

A special node representing a class instance.
Method __repr__ Undocumented
Method __str__ Undocumented
Method bool​_value Infer the truth value for an Instance
Method callable Undocumented
Method display​_type Undocumented
Method getitem Undocumented
Method pytype Undocumented
Class Variable special​_attributes Undocumented

Inherited from BaseInstance:

Method getattr Undocumented
Method igetattr inferred getattr
Method infer​_call​_result infer what a class instance is returning when called
Method _wrap​_attr wrap bound methods of attrs in a InstanceMethod proxies

Inherited from Proxy (via BaseInstance):

Method __getattr__ Undocumented
Method __init__ Undocumented
Method infer Undocumented
Instance Variable _proxied Undocumented
def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def bool_value(self, context=None): (source)

Infer the truth value for an Instance

The truth value of an instance is determined by these conditions:

  • if it implements __bool__ on Python 3 or __nonzero__ on Python 2, then its bool value will be determined by calling this special method and checking its result.
  • when this method is not defined, __len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither __len__() nor __bool__(), all its instances are considered true.
def callable(self): (source)

Undocumented

def display_type(self): (source)
def getitem(self, index, context=None): (source)