what are PyObject *globals and PyObject *locals ?

Discussion in 'Python' started by Olivier Sessink, Feb 24, 2005.

  1. Hi all,

    I want to make a value available to the global namespace of an embedded
    python interpreter. Several functions of the Python/C API feature a
    PyObject *globals and a PyObject *locals, so my guess is that these can be
    used for this purpose. Unfortunately, the Python/C API does not describe
    how this works.

    If I want for example, to create a variable MyVar that can be read by the
    python code in some filename, to be run with PyRun_AnyFile();, how can I
    do this?

    Or do I misunderstand the API, and can Py_InitModule() register both
    functions *and* variables? (and how to register the variable then?)

    regards,
    Olivier

    (I know extending is the preferred solution, unfortunately I was not aware
    of this some years ago)

    ------------ And now a word from our sponsor ------------------
    For a quality usenet news server, try DNEWS, easy to install,
    fast, efficient and reliable. For home servers or carrier class
    installations with millions of users it will allow you to grow!
    ---- See http://netwinsite.com/sponsor/sponsor_dnews.htm ----
     
    Olivier Sessink, Feb 24, 2005
    #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. Giles Brown

    Question about "exec in globals, locals"

    Giles Brown, Jul 4, 2003, in forum: Python
    Replies:
    2
    Views:
    361
    Adrien Di Mascio
    Jul 4, 2003
  2. tedsuzman
    Replies:
    2
    Views:
    7,094
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  3. Ted
    Replies:
    1
    Views:
    470
    Duncan Booth
    Jul 22, 2004
  4. Faisal Alquaddoomi

    Globals, Locals Dictionaries + Callbacks Question

    Faisal Alquaddoomi, Dec 21, 2005, in forum: Python
    Replies:
    3
    Views:
    366
    Steve Holden
    Dec 22, 2005
  5. Paolo Pantaleo

    locals() and globals()

    Paolo Pantaleo, Oct 14, 2006, in forum: Python
    Replies:
    1
    Views:
    583
    Kay Schluehr
    Oct 14, 2006
Loading...

Share This Page