PyDict_GetItemString converse
Michael Hudson
mwh21 at cam.ac.uk
Mon Aug 28 15:37:05 EDT 2000
Randy Heiland <heiland at ncsa.uiuc.edu> writes:
> I know that, given a name of a variable, I can do:
>
> PyObject *result = PyDict_GetItemString(globals, varname);
>
> how do I do the converse -- given a PyObject, get its associated
> variable name?
You can't in general. If you're sure it's in the dictionary
"globals", I think the moral equivalent of
for (key,value) in globals.items():
if value is result:
return key
is your best bet.
Cheers,
M.
--
In general, I'd recommend injecting LSD directly into your temples,
Syd-Barret-style, before mucking with Motif's resource framework.
The former has far lower odds of leading directly to terminal
insanity. -- Dan Martinez
More information about the Python-list
mailing list