Dict/List manipulation from C
Alex
cut_me_out at hotmail.com
Thu Aug 24 10:48:00 EDT 2000
> Right now I'm having to retrieve the (key,value) list, then loop
> through each entry in the passed dictionary calling
> SetItem(key,value). Seems a bit of overkill when in Python itself I
> can just say dict1 = dict2.
dict1 = dict2 just makes a new reference to the old dictionary, which is
not what you're describing with your loop.
I think the PyDict_Copy function does what you want. Something like
PyObject *NewDictionary;
NewDictionary = PyDict_Copy(OldDictionary);
if (!NewDictionary) {return NULL};
> Right now I'm inserting two additional paths to the head of the Python
> 'path' list, but what I would rather do is remove all existing entries
> from the list then add my two entries. I can see no way to remove
> list entries from the 'C' side. But, if anyone can tell me a better
> way to override the Python path without mucking with this variable,
> that would be great too!
Why do you want to do this on the C side? Wouldn't
sys.path = [my_two_entries]
be much easier?
Alex.
--
To succeed in the world it is not enough to be stupid; you must also be
well-mannered. -- Voltaire
More information about the Python-list
mailing list