***
Your mail has been scanned by InterScan MSS.
***
Hello,
Sorry, I very new in programming and the use of the classes still unknown.
I'm really interested to apply the right one as far as the results aren't as
expected.
Here's the example:
from poplib
I'm doing some evil things in Python and I would find it useful to
determine which class a method is bound to when I'm given a method
pointer.
For example:
class Foo(object):
def somemeth(self):
return 42
class Bar(Foo):
def othermethod(self):
return 42
Is
[vic]
> I'm doing some evil things in Python and I would find it useful to
> determine which class a method is bound to when I'm given a method
> pointer.
Here you go:
>>> class Foo:
... def bar(self):
... pass
...
>>> Foo.bar.im_class
>>&
ntro.html
but I was hoping for an automatic way of resolving this.
vic
On Fri, 25 Feb 2005 14:54:34 +, Richie Hindle <[EMAIL PROTECTED]> wrote:
>
> [vic]
> > I'm doing some evil things in Python and I would find it useful to
> > determine which class a method is bound
Victor Ng wrote:
> I'm doing some evil things in Python and I would find it useful to
> determine which class a method is bound to when I'm given a method
> pointer.
>
> For example:
>
> class Foo(object):
> def somemeth(self):
> return 42
>
wrote:
>
> > I'm doing some evil things in Python and I would find it useful to
> > determine which class a method is bound to when I'm given a method
> > pointer.
> >
> > For example:
> >
> > class Foo(object):
> > def somem
Peter Otten wrote:
import inspect
class Foo(object):
> ... def foo(self): pass
> ...
class Bar(Foo):
> ... def bar(self): pass
> ...
def get_imp_class(method):
> ... return [t for t in inspect.classify_class_attrs(method.im_class)
> if t[-1] is method.im_func][0][2]
Victor Ng wrote:
I'm doing some evil things in Python and I would find it useful to
determine which class a method is bound to when I'm given a method
pointer.
For example:
class Foo(object):
def somemeth(self):
return 42
class Bar(Foo):
def othermethod(self):
re
In article <[EMAIL PROTECTED]>,
Victor Ng <[EMAIL PROTECTED]> wrote:
>I'm doing some evil things in Python and I would find it useful to
>determine which class a method is bound to when I'm given a method
>pointer.
I don't know where (or if) it's docume
In article <[EMAIL PROTECTED]>,
Victor Ng <[EMAIL PROTECTED]> wrote:
>No - that doesn't work, im_class gives me the current class - in the
>case of inheritance, I'd like to get the super class which provides
>'bar'.
Oh my. You said you were doing something evil, but didn't say *how*
evil. What
Another way is to make a simple metaclass, setting an attribute (like
defining_class, or something) on each function object in the class
dictionary.
--
http://mail.python.org/mailman/listinfo/python-list
So I went digging through the documentation more and found the following:
http://docs.python.org/ref/types.html
There's a section titled "User-defined methods" which covers all the
im_self, im_class attributes and what they are responsible for.
vic
On 25 Feb 2005 10:42:06 -0800, [EMAIL PROTECTE
12 matches
Mail list logo