identifying new not inherited methods

George Sakkis george.sakkis at gmail.com
Tue Sep 26 13:22:45 EDT 2006


malkarouri at gmail.com wrote:

> George Sakkis wrote:
> [...]
> > I'd rather have it as a function, not attached to a specific class:
> >
>
> Thanks a lot George, that was what I was looking for. Got to
> understand/appreciate inspect more.
> Of course it works as a method. So, other than having it as a general
> utility, I presume there is no special reason to have it as a function
> rather than a method..

You're looking at it backwards; there's no particular reason this
should be a method of class A since it can be used for any arbitrary
object with no extra overhead. Now, if you intend to use it only for
instances of A and its subclasses, the only difference would be
syntactic; if you prefer x.list_cmds() from list_cmds(x), go with the
method.

George




More information about the Python-list mailing list