How to define own function in ctypes format?Help...

A forum for general discussion of the Python programming language.

How to define own function in ctypes format?Help...

Postby alabview » Mon Oct 28, 2013 6:18 pm

Hi,

I wish to know how to define a function in ctypes format

Code: Select all
def xfrange(start,stop,step):
    while start < stop:
        yield start
        start += step   


Code: Select all
c_START=ctypes.c_double(0)
c_END=ctypes.c_double(5)
c_STEPSIZE=ctypes.c_double(0.1)
for r in xfrange(c_START,c_END,c_STEPSIZE):
print (r)


The error what I get,
Code: Select all
Traceback (most recent call last):
  File "C:\INSTRDLL\SCP\CLOSEDLOOP.py", line 33, in <module>
    for r in xfrange(c_START,c_END,c_STEPSIZE):
  File "C:\INSTRDLL\SCP\CLOSEDLOOP.py", line 32, in xfrange
    start += step
TypeError: unsupported operand type(s) for +=: 'c_double' and 'c_double'


And, not sure the error is caused by non ctypes function. Please advice.

MAny Thanks.
alabview
 
Posts: 22
Joined: Mon Sep 16, 2013 1:48 pm

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest