Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work, matcher):

Re: Accessing a method from within its own code

2009-11-02 Thread Dave Angel
Paddy O'Loughlin wrote: Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work,

Re: Accessing a method from within its own code

2009-11-02 Thread Gerard Flanagan
Paddy O'Loughlin wrote: Hi, I was wondering if there was a shorthand way to get a reference to a method object from within that method's code. Take this code snippet as an example: import re class MyClass(object): def find_line(self, lines): if not hasattr(MyClass.do_work,

Re: Accessing a method from within its own code

2009-11-02 Thread Paddy O'Loughlin
I suspect that the inspection module has your answer, but that it'll be bulkier, and much slower than just doing what you're doing already. Hmm. Yeah, it does appear to be bulky. I don't think it's really any more use than what I'm doing already. Why not use the default arguments gimmick?

Re: Accessing a method from within its own code

2009-11-02 Thread Dave Angel
Paddy O'Loughlin wrote: I suspect that the inspection module has your answer, but that it'll be bulkier, and much slower than just doing what you're doing already. Hmm. Yeah, it does appear to be bulky. I don't think it's really any more use than what I'm doing already. Why not use the