Skip to content

missing haskey, get, etcetera? #148

Closed
@stevengj

Description

@stevengj

If I have a Python dictionary object or similar:

julia> d = pyeval("{'foo': 1, 'bar': 2}", Main)
Python dict: {'foo': 1, 'bar': 2}

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions