-2

I am looking at a code given to me by a co-worker who no longer works with us.

I have a list variable called rx.

>> type(rx)

type 'list'

When I go to look inside rx[0] I get this:

>> rx[0]

<Thing.thing.stuff.Rx object at 0x10e1e1c10>

Can anyone translate what this means? And, more importantly, how can I see what is inside this object within the rx list?

Any help is appreciated.

brennan
  • 3,392
  • 24
  • 42
Darcy
  • 619
  • 2
  • 5
  • 15

1 Answers1

6

Start with help: help(rx[0])

# example python object
class Employee:
    """Common base class for all employees."""
    empCount = 0


help(Employee)

Output:

Help on class Employee in module __main__:

class Employee(builtins.object)
 |  Common base class for all employees.
 |  
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  empCount = 0

If that's not enough info check out the inspect module.

Inspect has a lot of methods that might be useful, like getmembers and getdoc:

import inspect

inspect.getdoc(Employee)  # 'Common base class for all employees.'

for name, data in inspect.getmembers(Employee):
    if name == '__builtins__':
        continue
    print('%s :' % name, repr(data))

Output:

__class__ : <class 'type'>
__delattr__ : <slot wrapper '__delattr__' of 'object' objects>
__dict__ : mappingproxy({'__module__': '__main__', '__dict__': <attribute '__dict__' of 'Employee' objects>, '__weakref__': <attribute '__weakref__' of 'Employee' objects>, 'empCount': 0, '__doc__': 'Common base class for all employees.'})
__dir__ : <method '__dir__' of 'object' objects>
__doc__ : 'Common base class for all employees.'
__eq__ : <slot wrapper '__eq__' of 'object' objects>
__format__ : <method '__format__' of 'object' objects>
__ge__ : <slot wrapper '__ge__' of 'object' objects>
__getattribute__ : <slot wrapper '__getattribute__' of 'object' objects>
__gt__ : <slot wrapper '__gt__' of 'object' objects>
__hash__ : <slot wrapper '__hash__' of 'object' objects>
__init__ : <slot wrapper '__init__' of 'object' objects>
__le__ : <slot wrapper '__le__' of 'object' objects>
__lt__ : <slot wrapper '__lt__' of 'object' objects>
__module__ : '__main__'
__ne__ : <slot wrapper '__ne__' of 'object' objects>
__new__ : <built-in method __new__ of type object at 0x108a69d20>
__reduce__ : <method '__reduce__' of 'object' objects>
__reduce_ex__ : <method '__reduce_ex__' of 'object' objects>
__repr__ : <slot wrapper '__repr__' of 'object' objects>
__setattr__ : <slot wrapper '__setattr__' of 'object' objects>
__sizeof__ : <method '__sizeof__' of 'object' objects>
__str__ : <slot wrapper '__str__' of 'object' objects>
__subclasshook__ : <built-in method __subclasshook__ of type object at 0x7faa994086e8>
__weakref__ : <attribute '__weakref__' of 'Employee' objects>
empCount : 0
brennan
  • 3,392
  • 24
  • 42