Embedding: Howto get object's dictonary

Discussion in 'Python' started by Oliver Eichler, Oct 13, 2004.

  1. Hi,

    having a PyObject pointer to a python object, how can I get the object's
    dictionary, if there is any. There seems to be _PyObject_GetDictPtr() but
    this looks quite like a internal "you must not use it".

    Thanks for help

    Oliver
     
    Oliver Eichler, Oct 13, 2004
    #1
    1. Advertising

  2. Oliver Eichler wrote:

    > having a PyObject pointer to a python object, how can I get the object's
    > dictionary, if there is any. There seems to be _PyObject_GetDictPtr() but
    > this looks quite like a internal "you must not use it".


    I'd say it's more of an "be very careful", along the lines of _PyString_Resize,
    _PyTuple_Resize, and other functions that can cause all sorts of trouble if you
    use them carelessly.

    (note btw that the function returns a pointer to the dictionary pointer, not the
    dictionary itself)

    </F>
     
    Fredrik Lundh, Oct 13, 2004
    #2
    1. Advertising

  3. Fredrik Lundh wrote:

    > Oliver Eichler wrote:
    >
    >> having a PyObject pointer to a python object, how can I get the object's
    >> dictionary, if there is any. There seems to be _PyObject_GetDictPtr() but
    >> this looks quite like a internal "you must not use it".

    >
    > I'd say it's more of an "be very careful", along the lines of
    > _PyString_Resize, _PyTuple_Resize, and other functions that can cause all
    > sorts of trouble if you use them carelessly.
    >
    > (note btw that the function returns a pointer to the dictionary pointer,
    > not the dictionary itself)
    >

    yep, I've noticed. Leaving me still with the uncertain feeling wether there
    is a better way to get the dict, or not. I mean, why is there no
    PyObject_GetDictPtr() returning a new or borrowed reference? Any other
    reason than "Nobody did implement it, so far."?


    Oliver
    > </F>
     
    Oliver Eichler, Oct 13, 2004
    #3
    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. Andreas Beresko

    Dictonary

    Andreas Beresko, Feb 22, 2005, in forum: Java
    Replies:
    2
    Views:
    576
    Andreas Beresko
    Feb 22, 2005
  2. Chris Lieb
    Replies:
    8
    Views:
    10,892
  3. Michael Sampson

    Loading a Cookie from a Dictonary

    Michael Sampson, Feb 1, 2004, in forum: Python
    Replies:
    3
    Views:
    297
    John J. Lee
    Feb 7, 2004
  4. =?iso-8859-1?q?Gonzalo_Sainz-Tr=E1paga_=28GomoX=29

    Dictonary persistance weirdness

    =?iso-8859-1?q?Gonzalo_Sainz-Tr=E1paga_=28GomoX=29, Apr 10, 2005, in forum: Python
    Replies:
    3
    Views:
    341
    =?iso-8859-1?q?Gonzalo_Sainz-Tr=E1paga_=28GomoX=29
    Apr 11, 2005
  5. Replies:
    2
    Views:
    272
Loading...

Share This Page