Re: context aware execution

Discussion in 'Python' started by Bart Thate, Dec 19, 2012.

  1. Bart Thate

    Bart Thate Guest

    Thanks for your response Chris !

    Ha ! the job of the mad man is todo the things the are not "advisable" and
    see what gives. Like why it is not advisable and, if possible, their are
    ways to achieve things that are previously overseen.

    i already do a lot of travelling of the callstack to see from where a
    function is called. mostely for logging purposes, like what plugin
    registered this callback etc.

    lately i also had the need to log the variable name of a object, and the
    thought of be able to "break out of the namespace" concept got me thinking

    what i am thinking of is code that can examine the context it is run in.
    The object, when called can figure out in what kind of space it is living
    in and discover what kind of API other objects in the space offer.

    This is a pre function that gets called before the actual function/method
    and can thus determine if a certain request can be fullfilled.

    I bet a decorator could be made, in which i can assign certain caller
    context references into variables in the function/method ?

    I use 1 generic parameter object, in which i can stuff lots of things, but
    i rather have the function be able to see what is around ;]

    Think of sending JSON over the wire, reconstruct an object with it and then
    let the object figure out what it can and cannot do in this external
    environment.

    Code i use now is this:

    # life/plugs/context.py
    #
    #

    """ show context. """

    ## basic import

    import sys

    ## context command

    def context(event):
    result = []
    frame = sys._getframe()
    code = frame.f_back.f_code
    for i in dir(code): print("%s => %s" % (i, getattr(code, i)))
    del frame

    context.cmnd = "context"

    So much to explore ;]
     
    Bart Thate, Dec 19, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    9
    Views:
    716
    Gabriel Genellina
    Nov 14, 2007
  2. Bart Thate

    context aware execution

    Bart Thate, Dec 19, 2012, in forum: Python
    Replies:
    0
    Views:
    123
    Bart Thate
    Dec 19, 2012
  3. Chris Angelico

    Re: context aware execution

    Chris Angelico, Dec 19, 2012, in forum: Python
    Replies:
    0
    Views:
    135
    Chris Angelico
    Dec 19, 2012
  4. Wayne Werner

    Re: context aware execution

    Wayne Werner, Dec 19, 2012, in forum: Python
    Replies:
    0
    Views:
    117
    Wayne Werner
    Dec 19, 2012
  5. Michael Torrie

    Re: context aware execution

    Michael Torrie, Dec 20, 2012, in forum: Python
    Replies:
    0
    Views:
    119
    Michael Torrie
    Dec 20, 2012
Loading...

Share This Page