funcdict = {
  'mypackage.mymodule.myfunction': mypackage.mymodule.myfunction,
    ....
}

funcdictmyvar
Answer from Ignacio Vazquez-Abrams on Stack Overflow
๐ŸŒ
robmiles.com
robmiles.com โ€บ journal โ€บ 2018 โ€บ 9 โ€บ 27 โ€บ pointers-to-functions-in-c-and-python
Pointers to Functions in C# and Python โ€” robmiles.com
September 27, 2018 - The variable function_ref is made to refer to the function a_function and the function_ref variable can then be called as a function. Later in the program function_ref might store an integer, or string, or a reference to an object of type Cheese. Thatโ€™s how Python is.
Address: 31-38 Queen Street Hull HU1 1UU United Kingdom
Discussions

You can use pointers in python?
The * is not used for pointers in Python, but for packing and unpacking of collections. In an argument list, *args means that any additional positional arguments are collected in a tuple named args: def test(a, b, *args): print(a, b, args) test(1, 2, 3, 4, 5) 1 2 (3, 4, 5) Likewise, **kwargs means that any additional key-word arguments are collected in a dictionary named kwargs: def test(a, b, **kwargs): print(a, b, kwargs) test(a=1, b=2, c=3, d=4, e=5) 1 2 {'c': 3, 'd': 4, 'e': 5} By the way, the parameter list you posted works a little strangely in that form. The second positional argument would assign to verbose and only any positional arguments beyond that would go into args. It should be written like this: def runcmd(cmd, *args, verbose=False, **kwargs): Then verbose is a key-word only argument, as was probably intended. More on reddit.com
๐ŸŒ r/learnpython
19
2
April 26, 2022
How to pass a python function to a C function as a function pointer in Cython
Hi all, I am writing a cython class like this. cdef class Button: cdef CButton* ptr cdef object _onClick def __cinit__(self, ...): self.ptr = make_btn_ptr_in_C() @onClick.setter def onClick(self, pfunc): self._onClick = pfunc setClickHandler(self.ptr, self._onClick) This setClickHandler ... More on discuss.python.org
๐ŸŒ discuss.python.org
18
0
February 7, 2024
Let python call a C function pointer passed from the C Python API
I have C++ a void function pointer stored in a variable call. The pointed function takes an int and a char* as arguments. I have a python module containing this function: def yeah(x): x(int(0),"text argument") return "pointer called" As you can see I'm trying to use the argument x of the... More on thecodingforums.com
๐ŸŒ thecodingforums.com
2
November 16, 2009
C Python API: os.register_at_fork analogue with C function pointer arguments - Ideas - Discussions on Python.org
Rather than have to take a C function, make a python wrapper for it, use the c/python api to get the function pointer to os.register_at_fork(), and call it with the C functionโ€™s python wrapper as an argument, I propose adding a new PyOS_RegisterAtFork c/python ... More on discuss.python.org
๐ŸŒ discuss.python.org
1
March 3, 2023
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ turning-a-function-pointer-to-callable
Turning a Function Pointer to Callable - Python
April 2, 2019 - from llvm.core import Module, Function, Type, Builder mod = Module.new('example') f = Function.new(mod, Type.function( Type.double(), [Type.double(), Type.double()], False), 'foo') block = f.append_basic_block('entry') builder = Builder.new(block) x2 = builder.fmul(f.args[0], f.args[0]) y2 = builder.fmul(f.args[1], f.args[1]) r = builder.fadd(x2, y2) builder.ret(r) Output : <llvm.core.Instruction object at 0x10078e990> Code #5 : ... from llvm.ee import ExecutionEngine engine = ExecutionEngine.new(mod) ptr = engine.get_pointer_to_function(f) ptr Output :
๐ŸŒ
Google Groups
groups.google.com โ€บ g โ€บ cython-users โ€บ c โ€บ 0ouYUUa60R4
passing a pointer function to another function which can be called in python
September 24, 2017 - In that case, ars.normal would already be a wrapper of the function pointer, so in that case you'd need to write your function that is supposed to receive the function to accept a wrapper of that type and you'd have to figure out a way to access the pointer. Note that, if you go this route, your type-safety is entirely based on your ars.normal.argtypes definition. You should probably declare the return type somewhere as well. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Sorry again for my posts here: I ended up writing the following python function (wrapper) in order to get access to my "initial" and "sample" C-type functions: def py_ars(int ns, int m, double emax,
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ using-function-pointers-in-python
How to use Function Pointers in Python [4 Ways] | bobbyhadz
April 11, 2024 - The function pointer string is stored in a variable. We called the eval() function with the string and it resolved to the actual greet function from the another module. The second set of parentheses is used to invoke the greet function. However, notice that we still had to import the another module even though it's not directly used in our code. The argument we passed to the eval() function is parsed and evaluated as a Python expression.
Find elsewhere
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
How to pass a python function to a C function as a function pointer in Cython - Python Help - Discussions on Python.org
February 7, 2024 - Hi all, I am writing a cython class like this. cdef class Button: cdef CButton* ptr cdef object _onClick def __cinit__(self, ...): self.ptr = make_btn_ptr_in_C() @onClick.setter def onClick(self, pfunc): self._onClick = pfunc setClickHandler(self.ptr, self._onClick) This setClickHandler ...
๐ŸŒ
The Coding Forums
thecodingforums.com โ€บ archive โ€บ archive โ€บ python
Let python call a C function pointer passed from the C Python API | Python | Coding Forums
November 16, 2009 - Click to expand... Python can't call C function pointers. You have to write a function in C that accepts a CObject and some arguments, unpacks the arguments, retrieves the function pointer from the CObject, and calls it. Quick and dirty function that might do that (untested, not robust).
๐ŸŒ
Real Python
realpython.com โ€บ pointers-in-python
Pointers in Python: What's the Point? โ€“ Real Python
March 18, 2026 - Because you defined add_one() in this shared object, you can access it as if it were any other Python object. Before you call the function though, you should specify the function signature. This helps Python ensure that you pass the right type to the function. In this case, the function signature is a pointer to an integer.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-create-pointers-in-Python
How to create pointers in Python - Quora
Answer (1 of 7): It is not necessary, as labels will function as references to values automatically. Python restricts references to always point to some value. You cannot make a reference without an initializing value, even if it is [code ]None[/code]. Python functions return [code ]None[/code] b...
๐ŸŒ
Learn C++
learncpp.com โ€บ cpp-tutorial โ€บ function-pointers
20.1 โ€” Function Pointers โ€“ Learn C++
August 8, 2007 - In lesson 12.7 -- Introduction to pointers, you learned that a pointer is a variable that holds the address of another variable. Function pointers are similar, except that instead of pointing to variables, they point to functions!
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ c-api โ€บ function.html
Function Objects โ€” Python 3.14.8 documentation
Return true if o is a function object (has type PyFunction_Type). The parameter must not be NULL.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ using-pointers-in-python-using-ctypes
Using Pointers in Python using ctypes - GeeksforGeeks
July 23, 2025 - As the name suggests void pointer ... into any type and can hold data of any type. Since in Python the concept of pointers is not properly available or used we can't properly create a Void Pointer, as the POINTER function requires one argument i.e the data type....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-functions
Python Functions - GeeksforGeeks
Mutable objects like lists can be modified inside functions. Immutable objects like integers and strings remain unchanged. ... def myFun(x): x[0] = 20 b = [10, 11, 12, 13] myFun(b) print(b) def myFun2(x): x = 20 a = 10 myFun2(a) print(a) ... myFun(x) modifies the first element of the list and lists are mutable, so the original list changes. myFun2(x) assigns a new value to x. Integers are immutable, so the original value of a remains unchanged. Note: Python uses pass-by-object-reference, where functions receive references to objects instead of actual copies.
Published: 2 weeks ago
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Function_pointer
Function pointer - Wikipedia
July 27, 2026 - A function pointer, also called a subroutine pointer or procedure pointer, is a pointer referencing executable code, rather than data. Dereferencing the function pointer yields the referenced function, which can be invoked and passed arguments just as in a normal function call.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_functions_pointers.php
C Function Pointer
A function pointer is like a normal pointer, but instead of pointing to a variable, it points to a function.
๐ŸŒ
Python
python-list.python.narkive.com โ€บ stqBvePE โ€บ calling-c-function-pointers-from-python
Calling C Function Pointers from Python
Interesting -- it should be possible ... be that easy, since you would need to find a way to call a function pointer with a variable number of arguments in C. Look at the 'dl' module in the standard Python distribution....
๐ŸŒ
Filipekberg
filipekberg.se โ€บ 2009 โ€บ 11 โ€บ 30 โ€บ function-pointers-in-c-and-python-and-their-possible-usage
Function pointers in C and Python and their possible usage
May 31, 2021 - Imagine the scenario where you might want to performe some calculation but you don't know what type of API the end user which will end up using your API have. Let's say that the method "square" ( x^x ) would not be defined. So you might end up having to use function pointers, where you ask the user to suppy the function for calculating square of x. In Python the Square function for x^x will look like this
๐ŸŒ
Python.org
discuss.python.org โ€บ ideas
C Python API: os.register_at_fork analogue with C function pointer arguments - Ideas - Discussions on Python.org
March 3, 2023 - Python can register callbacks using os.register_at_fork() to occur surrounding forks. The c/python api documents functions like PyOS_BeforeFork(), but does not provide a way to register functions implemented in C to occuโ€ฆ
๐ŸŒ
Cprogramming
cprogramming.com โ€บ tutorial โ€บ function-pointers.html
Function Pointers in C and C++ - Cprogramming.com
How to begin Get the book ยท C tutorial C++ tutorial Game programming Graphics programming Algorithms More tutorials