Which class?

2006-10-15 Thread Fulvio
*** 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

Is there way to determine which class a method is bound to?

2005-02-25 Thread Victor Ng
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

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Richie Hindle
[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 >>&

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Victor Ng
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

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Peter Otten
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 >

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread 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 somem

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Peter Otten
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]

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Robin Becker
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

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Roy Smith
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

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread Roy Smith
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

Re: Is there way to determine which class a method is bound to?

2005-02-25 Thread [EMAIL PROTECTED]
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

Re: Is there way to determine which class a method is bound to?

2005-03-04 Thread Victor Ng
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