On 20 Giu, 06:52, John Nagle <[EMAIL PROTECTED]> wrote:
> billiejoex wrote:
> > Hi there,
> > unfortunately, I'm compelled to apply a sort of monkey patching at the
> > code of an existing libreary that I can't modify directly.
> ...
>
> > ...(if it is possible) how can I get, from method "called",
billiejoex wrote:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
...
>
> ...(if it is possible) how can I get, from method "called", the name
> of function/method that called it (in this case "caller
En Tue, 19 Jun 2007 18:06:40 -0300, billiejoex <[EMAIL PROTECTED]> escribió:
> On 19 Giu, 22:50, Stefan Sonnenberg-Carstens
> <[EMAIL PROTECTED]> wrote:
>> billiejoex schrieb:
>>
>>
>> > ...(if it is possible) how can I get, from method "called", the name
>> > of function/method that called it (in
billiejoex wrote:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
> Here's my question
> Having such code:
>
> class test:
>
> def caller(self):
> self.b()
>
> def called(self):
>
billiejoex wrote:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
> Here's my question
> Having such code:
>
> class test:
>
> def caller(self):
> self.b()
>
> def called(self):
>
On Jun 19, 10:50 pm, Stefan Sonnenberg-Carstens
<[EMAIL PROTECTED]> wrote:
> billiejoex schrieb:
> > ...(if it is possible) how can I get, from method "called", the name
> > of function/method that called it (in this case "caller")?
> inspect.stack is your friend ;-)
If you start doing such thing
On 19 Giu, 22:50, Stefan Sonnenberg-Carstens
<[EMAIL PROTECTED]> wrote:
> billiejoex schrieb:
>
>
>
> > Hi there,
> > unfortunately, I'm compelled to apply a sort of monkey patching at the
> > code of an existing libreary that I can't modify directly.
> > Here's my question
> > Having such code:
>
> ...(if it is possible) how can I get, from method "called", the name
> of function/method that called it (in this case "caller")?
The traceback module will give you access to the call stack.
>>> import traceback
>>> def foo():
... return traceback.extract_stack()
...
>>> def bar():
...
billiejoex schrieb:
> Hi there,
> unfortunately, I'm compelled to apply a sort of monkey patching at the
> code of an existing libreary that I can't modify directly.
> Here's my question
> Having such code:
>
> class test:
>
> def caller(self):
> self.b()
>
> def called(self):
>
Hi there,
unfortunately, I'm compelled to apply a sort of monkey patching at the
code of an existing libreary that I can't modify directly.
Here's my question
Having such code:
class test:
def caller(self):
self.b()
def called(self):
pass
...(if it is possible) how can I
10 matches
Mail list logo