memcpy

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Sep 10 16:31:07 EDT 2007


On Mon, 10 Sep 2007 11:38:50 -0700, Tim wrote:

> How do I memcpy from a pointer to an array of floats in python?
> 
> I get errors: NameError: global name 'row' is not defined

Well than the (global) name `row` is not defined.  Quite clear message,
isn't it?  ;-)

> I want to be able to get the row[i] array element. In C I would
> normally place the address of row as the first argument.
> 
> cdll.msvcrt.memcpy( row, pData, 256 )
> 
> 
> If I define row as the following I also get the following error:
> 
> row = ones( TOTAL_PARAMETER_ENTRIES, dtype=float )
> 
> ArgumentError: argument 1: <type 'exceptions.TypeError'>: Don't know
> how to convert parameter 1

You don't give enough information so we have to guess.  For example I
guess the `ones()` function comes from one of the packages `numeric`,
`numarray` or `numpy`!?

This function returns a Python object.  You can't use arbitrary Python
objects with `ctypes`.  `memcpy` expects a pointer not an object.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list