Re: Finding the public callables of self

2006-02-09 Thread Lonnie Princehouse
Ha! I didn't realize that was getmembers' implementation. What a hack ;-) In fact, your way is faster, since getmembers is taking the time to sort its results (presumably so that repeated calls to the same object will yield the same list; I don't think dir has a guaranteed ordering) -- http://

Re: Finding the public callables of self

2006-02-09 Thread Russell Warren
> import inspect > myCallables = [name for name, value in inspect.getmembers(self) if not > name.startswith('_') and callable(value)] Thanks. I forgot about the inspect module. Interestingly, you've also answered my question more than I suspect you know! Check out the code for inspect.getmember

Re: Finding the public callables of self

2006-02-09 Thread bruno at modulix
Sion Arrowsmith wrote: > Russell Warren <[EMAIL PROTECTED]> wrote: (snip) > At first I thought self.__dict__ would do it, but callable methods >>seem to be excluded so I had to resort to dir, and deal with the >>strings it gives me. > > This last sentence suggests to me something like: > > a

Re: Finding the public callables of self

2006-02-09 Thread Sion Arrowsmith
Russell Warren <[EMAIL PROTECTED]> wrote: >Is there any better way to get a list of the public callables of self >other than this? > >myCallables = [] >classDir = dir(self) >for s in classDir: > attr = self.__getattribute__(s) > if callable(attr) and (not s.startswith("_")): >

Re: Finding the public callables of self

2006-02-09 Thread Kent Johnson
Russell Warren wrote: > Is there any better way to get a list of the public callables of self > other than this? > > myCallables = [] > classDir = dir(self) > for s in classDir: > attr = self.__getattribute__(s) > if callable(attr) and (not s.startswith("_")): > myC

Re: Finding the public callables of self

2006-02-09 Thread Lonnie Princehouse
import inspect myCallables = [name for name, value in inspect.getmembers(self) if not name.startswith('_') and callable(value)] Instance methods aren't in self.__dict__ because they're a part of the class. To made a comprehensive list of all the attributes available to an instance, you have to t

Finding the public callables of self

2006-02-09 Thread Russell Warren
Is there any better way to get a list of the public callables of self other than this? myCallables = [] classDir = dir(self) for s in classDir: attr = self.__getattribute__(s) if callable(attr) and (not s.startswith("_")): myCallables.append(s) #collect the names (n