0

In python, I make a call to a calculate function inn my pyx file, which then calls other cdef functions.

python function:

def getCoord():
   array = ['A','B','C','D']
   px = 5
   py = 6
   move = pyxFile.calculateCoord( array, x, y )

pyx function:

def calculateCoord( array, px, py):
   cdef vector[ char ] b

   for i in range( len( array) ):
      b.push_back( array[ i ] )

   return search( b, px, py )

I'm trying to pass a python array of characters to a vector[char] for use in my cdef functions, but my error is an integer is required on the line b.push_back( array[ i ] )

x and y are integers

search (a cdef function) returns a tuple of integers

1 Answer 1

1

Your inputs are length-1 strings rather than chars. I know this seems like it should be identical, but it isn't.

You can use ord to get the integer value of a length-1 string:

  b.push_back( ord(array[ i ]) )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.