Re: simple(?) Python C module question

2010-11-17 Thread Dan Stromberg
On Wed, Nov 17, 2010 at 7:42 PM, Terry Reedy wrote: > On 11/17/2010 7:25 PM, Mark Crispin wrote: > > Have you looked at ctypes? It's not suitable for all libraries, but >>> it can often obviate the need to write any C code: >>> http://docs.python.org/release/2.6.6/library/ctypes.html#module-ctyp

Re: simple(?) Python C module question

2010-11-17 Thread Terry Reedy
On 11/17/2010 7:25 PM, Mark Crispin wrote: Have you looked at ctypes? It's not suitable for all libraries, but it can often obviate the need to write any C code: http://docs.python.org/release/2.6.6/library/ctypes.html#module-ctypes Hmm. I don't think that it helps, especially as I don't reall

Re: simple(?) Python C module question

2010-11-17 Thread Mark Crispin
On Thu, 18 Nov 2010, Mark Wooding posted: [snip] Whoo-hoo! That's exactly what I was looking for. If we ever meet in person, I owe you a beer, sir. And by that I mean real beer (from what we call a "microbrew"), not Budweiser... :) -- Mark -- http://panda.com/mrc Democracy is two wolves

Re: simple(?) Python C module question

2010-11-17 Thread Mark Wooding
Mark Crispin writes: > I have a Python module written in C that interfaces with an external C > library. Basically, the project is to make it possible to use that > library from Python scripts. If you know who I am, you can guess > which library. :) You have your very own Wikipedia page, so o

Re: simple(?) Python C module question

2010-11-17 Thread Mark Crispin
On Wed, 17 Nov 2010, Grant Edwards posted: Hey, it's the IMAP guy! Get 'im! Busted! :p Alright, here's the full story. As may be obvious to some, the module is to be a Python interface into c-client. What may not be obvious is that this is for QA automation. The consumers of this module

Re: simple(?) Python C module question

2010-11-17 Thread geremy condra
On Wed, Nov 17, 2010 at 3:35 PM, Grant Edwards wrote: > On 2010-11-17, Mark Crispin wrote: > > Hey, it's the IMAP guy!  Get 'im! > >> I have a Python module written in C that interfaces with an external >> C library.  Basically, the project is to make it possible to use that >> library from Pytho

Re: simple(?) Python C module question

2010-11-17 Thread Chris Rebert
On Wed, Nov 17, 2010 at 3:18 PM, Mark Crispin wrote: > I have a Python module written in C that interfaces with an external C > library.  Basically, the project is to make it possible to use that library > from Python scripts.  If you know who I am, you can guess which library.  :) > > I have got

Re: simple(?) Python C module question

2010-11-17 Thread Grant Edwards
On 2010-11-17, Mark Crispin wrote: Hey, it's the IMAP guy! Get 'im! > I have a Python module written in C that interfaces with an external > C library. Basically, the project is to make it possible to use that > library from Python scripts. If you know who I am, you can guess > which library.

simple(?) Python C module question

2010-11-17 Thread Mark Crispin
This is something that ought to be simple, but going through the documentation hasn't come up with the answer. Hopefully someone can answer it faster than I can figure it out from the documentation. I am using Python 2.6 for a project. I do not have a choice in the matter, so telling me to u

Re: C Module question

2008-11-14 Thread Gabriel Genellina
En Mon, 10 Nov 2008 11:44:44 -0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: On Nov 10, 2:23 pm, Floris Bruynooghe <[EMAIL PROTECTED]> wrote: Sorry, I probably should have mentioned you want to cast the object to PyFileObject and then use the PyFile_AsFile() function to get the FILE*

Re: C Module question

2008-11-10 Thread greg
[EMAIL PROTECTED] wrote: Sadly this doesn't work on "file-like" objects like those that are created by opening bz2 files (using the bz2 lib). If the C code you're calling requires a FILE *, then you're out of luck. There's no way of getting a FILE * from an object that's not based on an actual

Re: C Module question

2008-11-10 Thread John Machin
On Nov 11, 12:55 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 10 Nov 2008 05:44:44 -0800, [EMAIL PROTECTED] wrote: > > All in all I must say that implementing a C extension is a piece of > > cake. Had I known that it was this straightforward I wouldn't have asked > > my questio

Re: C Module question

2008-11-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Nov 2008 05:44:44 -0800, [EMAIL PROTECTED] wrote: > All in all I must say that implementing a C extension is a piece of > cake. Had I known that it was this straightforward I wouldn't have asked > my questions in the first place. Making the whole thing more robust will > be a bit more d

Re: C Module question

2008-11-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Nov 2008 05:36:58 -0800, [EMAIL PROTECTED] wrote: > On Nov 10, 1:16 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Mon, 10 Nov 2008 03:11:06 -0800, [EMAIL PROTECTED] wrote: >> > 1. How can I pass a file-like object into the C part? The PyArg_* >> > functions can convert o

Re: C Module question

2008-11-10 Thread [EMAIL PROTECTED]
On Nov 10, 2:23 pm, Floris Bruynooghe <[EMAIL PROTECTED]> wrote: > Sorry, I probably should have mentioned you want to cast the object to > PyFileObject and then use the PyFile_AsFile() function to get the > FILE* handle. Yes, I figured that out by now. Sadly this doesn't work on "file-like" obje

Re: C Module question

2008-11-10 Thread [EMAIL PROTECTED]
On Nov 10, 1:16 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Mon, 10 Nov 2008 03:11:06 -0800, [EMAIL PROTECTED] wrote: > > 1. How can I pass a file-like object into the C part? The PyArg_* > > functions can convert objects to all sort of types, but not FILE*. > > http://docs.python.

Re: C Module question

2008-11-10 Thread Floris Bruynooghe
On Nov 10, 1:18 pm, Floris Bruynooghe <[EMAIL PROTECTED]> wrote: > On Nov 10, 11:11 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > 1. How can I pass a file-like object into the C part? The PyArg_* > > functions can convert objects to all sort of types, but not FILE*. > > Parse it as a g

Re: C Module question

2008-11-10 Thread Floris Bruynooghe
Hi On Nov 10, 11:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > 1. How can I pass a file-like object into the C part? The PyArg_* > functions can convert objects to all sort of types, but not FILE*. Parse it as a generic PyObject object (format string of "O" in PyArg_*), check the type a

Re: C Module question

2008-11-10 Thread Marc 'BlackJack' Rintsch
On Mon, 10 Nov 2008 03:11:06 -0800, [EMAIL PROTECTED] wrote: > 1. How can I pass a file-like object into the C part? The PyArg_* > functions can convert objects to all sort of types, but not FILE*. http://docs.python.org/c-api/file.html#PyFile_AsFile > 2. How can I preserve information needed in

Re: C Module question

2008-11-10 Thread Christian Heimes
[EMAIL PROTECTED] wrote: Hello, I'm trying to write a Python extension module in C for the first time. I have two questions: I have a much better suggestion: Use Cython! Although I'm pretty experienced with the Python C API, I prefer Cython over hand written C code for most stuff. It's s

C Module question

2008-11-10 Thread [EMAIL PROTECTED]
Hello, I'm trying to write a Python extension module in C for the first time. I have two questions: 1. How can I pass a file-like object into the C part? The PyArg_* functions can convert objects to all sort of types, but not FILE*. 2. How can I preserve information needed in the C part between