2016-08-31 14 views
-2

私は、もはや私たちと協力していない同僚によって私に与えられたコードを見ています。Pythonオブジェクトを検査する

私はrxというリスト変数を持っています。

>> type(rx) 

type 'list' 

私はRXの中を見に行く[0]私はこれを取得:

>> rx[0] 

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

誰もこれが何を意味するのか翻訳することはできますか?そして、もっと重要なのは、rxリスト内のこのオブジェクトの内部に何があるかをどのように見ることができるのでしょうか?

何か助けていただければ幸いです。 help

+1

それはあなたが印刷するときに何が起こるか、のrepr出力である

getmembersgetdocのように、役に立つかもしれない方法をたくさん持っているか点検しますそれ? –

+0

そしてここに[reprへのリンク](https://docs.python.org/2/library/functions.html#repr) – alfasin

+0

から始まります。 'Ring'オブジェクトのソースを' Thing.thing.stuff 'で検索します。 Rx'(または実際のもの) –

答えて

1

スタート:help(rx[0])

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


help(Employee) 

出力:

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 

それが十分で情報inspect moduleをチェックアウトしない場合。

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)) 

出力:

__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 
関連する問題