On this page
ctypes.pointer
Prev: ctypes.memset | Up: ctypes | Next: ctypes.resize
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.pointer
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import pointer
Signature & Overview
ctypes.pointer(obj)
Create a new pointer instance, pointing to 'obj'.
Usage
import ctypes
x = ctypes.c_int(99)
p = ctypes.pointer(x)
assert p.contents.value == 99
Gotchas
- Use
byref(x)instead when just passing to a C function:pointer()allocates a heavier Python pointer object.
REPL Inspect
from ctypes import pointer
help(pointer)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/memset Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/resize Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib