Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Awesome, thanks! On Thu, May 11, 2023 at 1:47 PM Eryk Sun wrote: > On 5/11/23, Jason Qian via Python-list wrote: > > > > in the Python, I have a array of string > > var_array=["Opt1=DG","Opt1=DG2"] > > I need to call c library and pass var_array as parameter > > In the argtypes, how do I se

Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Eryk Sun
On 5/11/23, Jason Qian via Python-list wrote: > > in the Python, I have a array of string > var_array=["Opt1=DG","Opt1=DG2"] > I need to call c library and pass var_array as parameter > In the argtypes, how do I set up ctypes.POINTER(???) for var_array? > > func.argtypes=[ctypes.c_void_p,ctyp

Re: Help on ctypes.POINTER for Python array

2023-05-11 Thread Jim Schwartz
I’m not sure this is the shortest method, but you could set up two python scripts to do the same thing and convert them to c using cython. I wouldn’t be able to read the c scripts, but maybe you could. Maybe someone else has a more direct answer. Sent from my iPhone > On May 11, 2023, at 10:

Help on ctypes.POINTER for Python array

2023-05-11 Thread Jason Qian via Python-list
Hi, Need some help, in the Python, I have a array of string var_array=["Opt1=DG","Opt1=DG2"] I need to call c library and pass var_array as parameter In the argtypes, how do I set up ctypes.POINTER(???) for var_array? func.argtypes=[ctypes.c_void_p,ctypes.c_int, ctypes.POINTER()] I

Re: Python Array

2016-03-30 Thread Cameron Simpson
On 30Mar2016 22:53, Stephen Hansen wrote: On Wed, Mar 30, 2016, at 10:34 PM, tdspe...@gmail.com wrote: as you can see the option element was added third but is the first one displayed. Is this just standard - I am using Python 3.5 The order of items in dictionaries is based on the hash value

Re: Python Array

2016-03-30 Thread Jussi Piitulainen
Stephen Hansen writes: > On Wed, Mar 30, 2016, at 10:34 PM, tdspe...@gmail.com wrote: >> as you can see the option element was added third but is the first one >> displayed. >> >> Is this just standard - I am using Python 3.5 > > The order of items in dictionaries is based on the hash value -- wh

Re: Python Array

2016-03-30 Thread Mark Lawrence via Python-list
On 31/03/2016 06:34, tdspe...@gmail.com wrote: I am creating the following aData = [] This is a Python list, not an array as the subject gives. # get my data from database for row in rows: aData.append({row["tierid"]:"name":row["tiername"],"description":row["tierdesc"],"option":row["tie

Re: Python Array

2016-03-30 Thread Stephen Hansen
On Wed, Mar 30, 2016, at 10:34 PM, tdspe...@gmail.com wrote: > as you can see the option element was added third but is the first one > displayed. > > Is this just standard - I am using Python 3.5 The order of items in dictionaries is based on the hash value -- which while stable, should be consi

Re: Python Array

2016-03-30 Thread Chris Angelico
On Thu, Mar 31, 2016 at 4:34 PM, wrote: > as you can see the option element was added third but is the first one > displayed. > Dictionaries don't have any order to them, so yes, this is something you'll have to accept. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Python Array

2016-03-30 Thread tdsperth
I am creating the following aData = [] # get my data from database for row in rows: aData.append({row["tierid"]:"name":row["tiername"],"description":row["tierdesc"],"option":row["tieroption"],"price":str(row["tierprice"])}}) when I display the output the order the data was entered is not w

Re: SWIG, c++ to Python: array of pointers (double pointer) not working

2009-03-17 Thread bobicanprogram
On Mar 14, 5:22 am, Matteo wrote: > Re-posting in more simple and precise terms from a previous > threadhttp://groups.google.it/group/comp.lang.python/browse_thread/thread/6... > > Problem: > SWIG doesn't properly wrap c++ arrays of pointers, therefore when you > try to call a c++ function which

SWIG, c++ to Python: array of pointers (double pointer) not working

2009-03-14 Thread Matteo
Re-posting in more simple and precise terms from a previous thread http://groups.google.it/group/comp.lang.python/browse_thread/thread/6dd7bd9a09b8a011/5119cf15ebfa38b8 Problem: SWIG doesn't properly wrap c++ arrays of pointers, therefore when you try to call a c++ function which requires them, a

Re: Rounding the elements of a Python array (numarray module)

2004-12-03 Thread Chris P.
S I wasn't sure if no one replied because a) this question was too dumb or b) this question was too hard... it was definitely the former. But I'll post the answer, anyway: I forgot to keep in mind - when reading the documentation, assume that a >>> from numarray import * occurred first. So h

Rounding the elements of a Python array (numarray module)

2004-11-30 Thread Chris P.
Hi. I have a very simple task to perform and I'm having a hard time doing it. Given an array called 'x' (created using the numarray library), is there a single command that rounds each of its elements to the nearest integer? I've already tried something like >>> x_rounded = x.astype(numarray.Int