[Python-bugs-list] [ python-Feature Requests-444805 ] More functions in the C API!

SourceForge.net noreply@sourceforge.net
Mon, 12 May 2003 17:29:47 -0700


Feature Requests item #444805, was opened at 2001-07-26 07:21
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=444805&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Martin Sjögren (msjogren)
Assigned to: Nobody/Anonymous (nobody)
Summary: More functions in the C API!

Initial Comment:
I was working with dictionaries in a C module today and
I was VERY surprised when I did not find a
PyDict_HasKey() function! Apparently the dict_has_key()
function is declared static and uses PyArg_ParseTuple()
to find out its arguments, and then goes directly down
to the object structure.

Is this really good? Is there another way to mimic the
has_key() behaviour? I ended up calling PyDict_Keys()
and looped over it several times instead, not exactly
nice. :(

----------------------------------------------------------------------

>Comment By: Brett Cannon (bcannon)
Date: 2003-05-12 17:29

Message:
Logged In: YES 
user_id=357491

There is ``int PyMapping_HasKeyString(PyObject *o, char *key)`` as 
specified in the Python/C API in section 6.4 (Mapping Protocol).  Does 
exactly what you want.

Closing this RFE as out of date.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-08-11 09:43

Message:
Logged In: YES 
user_id=21627

Just use PyDict_GetItem. If it returns NULL, the key is 
not in the dictionary; no need to clear any exceptions.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=444805&group_id=5470