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("_")): > myCallables.append(s) #collect the names (not funcs) > >I don't mean a shorter list comprehension or something that just drops >the line count, but whether or not I need to go at it through dir and >__getattribute__. This seems a bit convoluted and with python it often >seems there's something already canned to do stuff like this when I do >it. 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: attrs = set(s for s in dir(self) if not s.startswith('_')) myCallables = attrs.difference(a.__dict__) return list(myCallables) (which you can get down to one line if you want). -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- http://mail.python.org/mailman/listinfo/python-list