Re: Resolving declaring class of a method at runtime

2007-11-17 Thread Steven D'Aprano
On Sat, 17 Nov 2007 09:08:48 +0200, Janne Härkönen wrote: > I am sorry to have wasted your precious time in such oafish manner. And so you should be, and as soon as I can track down your address I'll be sending you the bill. *wink* -- Steven. -- http://mail.python.org/mailman/listinfo/pyth

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Janne Härkönen
On Nov 16, 2007 10:51 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen > wrote: > > >> X is an "old style" class. Most people probably shouldn't use old style > >> classes, for various reasons. To use new style classes, you inherit > >> from object

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Chris Mellon
On Nov 16, 2007 2:51 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen > wrote: > > >> X is an "old style" class. Most people probably shouldn't use old style > >> classes, for various reasons. To use new style classes, you inherit > >> from object:

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Alan
On Nov 16, 8:51 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > There should be a term for "optimization" techniques that actually slow > things down instead of speeding them up. > I belive those are the ones known as "premature optimizations", which sit at the root of all evil

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Steven D'Aprano
On Fri, 16 Nov 2007 19:02:25 +0200, Janne Härkönen wrote: >> X is an "old style" class. Most people probably shouldn't use old style >> classes, for various reasons. To use new style classes, you inherit >> from object: > > I am also aware of old and new style classes, this was the fastest way >

Re: Resolving declaring class of a method at runtime

2007-11-16 Thread Janne Härkönen
On Nov 15, 2007 11:07 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 15 Nov 2007 13:01:27 +0200, Janne Härkönen > wrote: > > Have you tried looking at dir(TheClass) to see what it lists? This is the first thing I did, but it shows both the inherited and own methods. > Also helpful is Th

Re: Resolving declaring class of a method at runtime

2007-11-15 Thread Steven D'Aprano
On Thu, 15 Nov 2007 13:01:27 +0200, Janne Härkönen wrote: > Hello, > > Is there a simple way to resolve declaring class of a method at runtime > ? Have you tried looking at dir(TheClass) to see what it lists? Also helpful is TheClass.__dict__.keys(). Python has powerful introspection abilities

Re: Resolving declaring class of a method at runtime

2007-11-15 Thread Bjoern Schliessmann
Janne Härkönen wrote: class X: > ... def x(self): > ...pass > ... class Y(X): > ... def y(self): > ...pass > ... y = Y() y.x.im_class > y.y.im_class > > > What I would like to find out is the declaring class of method x, > ie. class X How to do this ? The g

Re: Resolving declaring class of a method at runtime

2007-11-15 Thread Duncan Booth
"Janne Härkönen" <[EMAIL PROTECTED]> wrote: > $ python > Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) > [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin > Type "help", "copyright", "credits" or "license" for more information. class X: > ... def x(self): > ...pass >