Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: context aware execution

Reply
Thread Tools

Re: context aware execution

 
 
Chris Angelico
Guest
Posts: n/a
 
      12-19-2012
On Thu, Dec 20, 2012 at 2:57 AM, Bart Thate <> wrote:
> Hi All !
>
> Is is possible and if yes, is it more easily possible (i am thinking f_back
> maybe) to get the context of the caller when in a function ?
>
> Like to which variable name is this object assigned ?
>
> Or whatever of the callers context that might be of interest.
>
> I want in a function or method determine the context of my caller and adapt
> the functionality accordingly.


First off, please don't! Your code will be *extremely* confusing.

You can find out what function is calling you, eg by throwing an
exception and checking the traceback. My 3AM brain can't think of a
way to get the current thread's traceback without throwing, but there
may well be a way. (I also don't know of a way to get any other
thread's traceback, but that doesn't matter to this discussion.)

But finding out what variable name your return value is to be assigned
to isn't possible at all. For one thing, it might not be assigned
anywhere - it might be being ignored, or it might be used in some
other expression, or anything.

Usually, the best way to adapt to your caller's environment is to be
passed a parameter that specifies the change.

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: context aware execution Michael Torrie Python 0 12-20-2012 12:27 AM
Re: context aware execution Wayne Werner Python 0 12-19-2012 05:01 PM
Re: context aware execution Bart Thate Python 0 12-19-2012 04:51 PM
context aware execution Bart Thate Python 0 12-19-2012 03:57 PM
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57