Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Extending the answer of @mac taking in account the OP asked for a class instance variable and that he could also want to get info on "private" methods:</p> <pre><code>In [5]: class Foo(object): ...: def m1(self):pass ...: def m2(self):pass ...: In [6]: f = Foo() In [7]: lst = dir(f) In [8]: [m for m in lst if not m.endswith('__')] Out[8]: ['m1', 'm2'] </code></pre> <p>If you want the object method:</p> <pre><code>In [17]: getattr(Foo, 'm1') Out[17]: &lt;unbound method Foo.m1&gt; </code></pre> <p>or directly in the list comprehension from the instance:</p> <pre><code>In [18]: [getattr(f, m) for m in lst if not m.endswith('__')] Out[18]: [&lt;bound method Foo.m1 of &lt;__main__.Foo object at 0x00000000073DD1D0&gt;&gt;, &lt;bound method Foo.m2 of &lt;__main__.Foo object at 0x00000000073DD1D0&gt;&gt;] </code></pre> <p>Edit: So, given the examples you give in your link, maybe you are looking for something like:</p> <pre><code>class SomeClass: store = {0: 'someMethod', 1: 'someMethod1'} def __init__(self): print('__init__') def __del__(self): print('__del__') def get_dict(self): return [getattr(self, att) for idx, att in SomeClass.store.items()] def someMethod(): pass def someMethod1(): pass f = SomeClass() print f.get_dict() </code></pre> <p>That prints:</p> <pre><code>__init__ [&lt;bound method SomeClass.someMethod of &lt;__main__.SomeClass instance at 0x0000000 0026E2E08&gt;&gt;, &lt;bound method SomeClass.someMethod1 of &lt;__main__.SomeClass instance at 0x00000000026E2E08&gt;&gt;] __del__ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload