Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Is there a way to call function with key-word parameters? #30

Closed
gnani-g opened this issue Dec 29, 2015 · 2 comments
Closed

Is there a way to call function with key-word parameters? #30

gnani-g opened this issue Dec 29, 2015 · 2 comments
Assignees

Comments

@gnani-g
Copy link

gnani-g commented Dec 29, 2015

Tried a few ways. Even the following doesn't seem to work.

    // arguments
    _a := python.PyTuple_New(1)
    python.PyTuple_SET_ITEM(_a, 0, python.PyString_FromString(`test.mp3`))

    // keyword arguments
    _kw := python.PyDict_New()
    python.PyDict_SetItem(_kw, python.PyString_FromString(`v2_version`), python.PyInt_FromLong(3))

    // pack arguments
    _args := python.PyTuple_New(2)
    python.PyTuple_SET_ITEM(_args, 0, _a)
    python.PyTuple_SET_ITEM(_args, 1, _kw)

    // ID3 is a callable
    id3 := ID3.CallObject(_args)
    if id3 == nil {
        panic("failed")
    }
@sbinet sbinet self-assigned this Jan 4, 2016
sbinet added a commit that referenced this issue Jan 4, 2016
wrap PyObject_Call to handle functions with positional and keyword arguments.

Fixes #30.
@sbinet
Copy link
Owner

sbinet commented Jan 4, 2016

could you give 595aa16 a try?
see this example for instructions:
https://github.com/sbinet/go-python/blob/kw-args/tests/kw-args/main.go

@gnani-g
Copy link
Author

gnani-g commented Jan 4, 2016

@sbinet, The func Call works with and without arguments. Thanks.

@sbinet sbinet closed this as completed in 7074fff Jan 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants