You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it would be nice to be able to use haskey(d, x) (by checking whether PyObject_GetItem returns NULL), get(d, x, default) (similar to this), etcetera.
Maybe call it pyhasitem if you don't want to overload haskey. You already have a 2-arg pygetitem, so you could add a 3-arg version instead of overloading get. (Though I'm not sure what's wrong with overloading haskey and get, since you already overload getindex.)
The text was updated successfully, but these errors were encountered:
OK I've added pyhasitem, 3-arg pygetitem. I'm a little wary of this, as I try to stick to the Python API and these don't exist, but they are logical analogues of pyhasattr and pyhasitem.
If I have a Python dictionary object or similar:
it would be nice to be able to use
haskey(d, x)
(by checking whetherPyObject_GetItem
returnsNULL
),get(d, x, default)
(similar to this), etcetera.Maybe call it
pyhasitem
if you don't want to overloadhaskey
. You already have a 2-argpygetitem
, so you could add a 3-arg version instead of overloadingget
. (Though I'm not sure what's wrong with overloadinghaskey
andget
, since you already overloadgetindex
.)The text was updated successfully, but these errors were encountered: