Article 6HW7Z Python: Argument requires 3 arguments (1 given)

Python: Argument requires 3 arguments (1 given)

by
jmgibson1981
from LinuxQuestions.org on (#6HW7Z)
I'm trying to move toward python now. Working on bindings for my c library I've been working on. the prompt_input_getline() function I'm trying to call takes a single string parameter in the c code. I just cannot for the life of me sort this out. Been googling awhile. Here is the c function for reference.

Code:char *
prompt_input_getline(const char * prompt)
{
assert(prompt);

// declare & initialize
char * retval = NULL;

// print & get input
prompt_print(prompt);
retval = getline_stdin_mem_alloc();
if (retval) {
no_more_newline(retval);
}

return(retval);
}This is my current python testing. Maybe I'm trying something more advanced than I'm ready for.

Code:#!/usr/bin/python3
# python bindings for libjmgeneral.so

import ctypes
from ctypes import *
import pathlib

lib = pathlib.Path().absolute() / "/usr/local/lib/libjmgeneral.so"
libjmgen_lib = ctypes.CDLL(lib)

def random_gen(a, b):
return libjmgen_lib.random_gen(a, b)

def clear_ptr(a):
libjmgen_lib.clear_ptr(a)

def prompt_input_getline(a):
libjmgen_lib.prompt_input_getline.argtypes = [c_char_p,c_char_p,c_char_p]
libjmgen_lib.prompt_input_getline.restypes = c_char_p
b_string = a.encode('utf-8')
print(libjmgen_lib.prompt_input_getline("lol"))

prompt_input_getline("lol")
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments