extending and embedding python set_errno(valuesets the ctypes-private copy of the system errno variable returns the previous value set_last_error(valuesets the windows lasterror variable and returns the previous value sizeof(type_or_cobjreturns the size of ctypes type or object in bytes string_at(address [size]returns byte string representing size bytes of memory starting at address address if size is omittedit is assumed that the byte string is null-terminated wstring_at(address [size]returns unicode string representing size wide characters starting at address address if size is omittedthe character string is assumed to be null-terminated example the following example illustrates the use of the ctypes module by building an interface to the set of functions used in the very first part of this that covered the details of creating python extension modules by hand example py import ctypes _example ctypes cdll(/libexample so"int gcd(intintgcd _example gcd gcd argtypes (ctypes c_intctypes c_intgcd restype ctypes c_int int replace(char *schar olcdhchar newch_example replace argtypes (ctypes c_char_pctypes c_charctypes c_char_example replace restype ctypes c_int def replace(soldchnewch)sbuffer ctypes create_string_buffer(snrep _example replace(sbuffer,oldch,newchreturn (nrep,sbuffer valuedouble distance(point * point * class point(ctypes structure)_fields_ (" "ctypes c_double)(" "ctypes c_double_example distance argtypes (ctypes pointer(point)ctypes pointer(point)_example distance restype ctypes c_double def distance( , ) point(*ap point(*breturn _example distance(byref( ),byref( ) lib fl ff