Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Oscar Benjamin
On 28 Nov 2015 12:06, "James Oren" wrote: > > Hi all, this is my first time using the mailing list. > > I'm trying to learn how to use C to extend my code, and have already worked > out how to use ctypes. I'm now trying to learn the full C extension module > approach with Python.h and have worked

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Alan Gauld
On 28/11/15 15:59, Laura Creighton wrote: >> effort than ctypes to call a library function? I can't see any advantage, >> so what am I missing? > > Ctypes is slow. Aha. Performance is always the invisible feature. I only ever use ctypes to access OS features that don't have a Python equivalent

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 12:46:11 +, Alan Gauld writes: >On 28/11/15 12:29, Laura Creighton wrote: >> Most people I know have abandoned ctypes. They are using cffi instead. > >Really? Why? >I'd never heard of cffi before, but looking at the docs it seems like a >lot more >effort than c

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Peter Otten
Br. Sayan wrote: > I am doing the following : > > with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: > for line in infile: > if line.startswith(('R')): > outfile.write(line) > > It is executing without error but returns a blank file. Where is the >

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Alan Gauld
On 28/11/15 12:29, Laura Creighton wrote: > Most people I know have abandoned ctypes. They are using cffi instead. Really? Why? I'd never heard of cffi before, but looking at the docs it seems like a lot more effort than ctypes to call a library function? I can't see any advantage, so what am I m

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 12:22:12 +, Alan Gauld writes: >On 28/11/15 06:04, James Oren wrote: > >> I'm trying to learn how to use C to extend my code, and have already worked >> out how to use ctypes. I'm now trying to learn the full C extension module >> approach with Python.h and have

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 12:22:12 +, Alan Gauld writes: >On 28/11/15 06:04, James Oren wrote: > >> I'm trying to learn how to use C to extend my code, and have already worked >> out how to use ctypes. I'm now trying to learn the full C extension module >> approach with Python.h and have

Re: [Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread Alan Gauld
On 28/11/15 06:04, James Oren wrote: > I'm trying to learn how to use C to extend my code, and have already worked > out how to use ctypes. I'm now trying to learn the full C extension module > approach with Python.h and have worked through the Python doc and a couple > other examples. OK, This

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Alan Gauld
On 28/11/15 11:22, Br. Sayan wrote: > I am doing the following : > > with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: > for line in infile: > if line.startswith(('R')): > outfile.write(line) > > It is executing without error but returns a blank fil

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Br. Sayan
I am doing the following : with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: for line in infile: if line.startswith(('R')): outfile.write(line) It is executing without error but returns a blank file. Where is the problem? On 27 November 2015 at 22:

[Tutor] Help with returning a list object from a C extension.

2015-11-28 Thread James Oren
Hi all, this is my first time using the mailing list. I'm trying to learn how to use C to extend my code, and have already worked out how to use ctypes. I'm now trying to learn the full C extension module approach with Python.h and have worked through the Python doc and a couple other examples. Th

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 16:52:07 +0530, "Br. Sayan" writes: >I am doing the following : > >with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: >for line in infile: >if line.startswith(('R')): >outfile.write(line) > >It is executing without erro