Re: Slices when extending python with C++

2011-12-28 Thread rozelak
Great, it's working! Thank you very much, Robert! Dan T. - PŮVODNÍ ZPRÁVA - Od: "Robert Kern" Komu: python-list@python.org Předmět: Re: Slices when extending python with C++ Datum: 28.12.2011 - 14:18:36 > On 12/28/11 1:01 PM, roze...@volny.cz wrote: > > Dear R

Re: Slices when extending python with C++

2011-12-28 Thread Robert Kern
On 12/28/11 1:01 PM, roze...@volny.cz wrote: Dear Robert, thank you very much for your answer. I understand what you mean and I have looked at slice object and C-api methods it provides. It should be easy to implement it. The only question is how exactly yo implement the general getter, since s

Re: Slices when extending python with C++

2011-12-28 Thread rozelak
another way? Thank you very much again. Regards, Dan - PŮVODNÍ ZPRÁVA - Od: "Robert Kern" Komu: python-list@python.org Předmět: Re: Slices when extending python with C++ Datum: 28.12.2011 - 10:24:42 > On 12/27/11 11:02 PM, roze...@volny.cz wrote: > > Hallo, > &g

Re: Slices when extending python with C++

2011-12-28 Thread Robert Kern
On 12/27/11 11:02 PM, roze...@volny.cz wrote: Hallo, I have kind of special question when extening python with C++ implemented modules. I try to implement a class, behaving also like an array. And I need to implement slice-getters. I implemented PySequenceMethods.sq_slice to get "simple" slices

Re: Slices when extending python with C++

2011-12-27 Thread Ian Kelly
2011/12/27 : > Hallo, > I have kind of special question when extening python with C++ > implemented modules. > > I try to implement a class, behaving also like an array. And I need > to implement slice-getters. I implemented PySequenceMethods.sq_slice > to get "simple" slices like: > > myobj[x:y]

Slices when extending python with C++

2011-12-27 Thread rozelak
Hallo, I have kind of special question when extening python with C++ implemented modules. I try to implement a class, behaving also like an array. And I need to implement slice-getters. I implemented PySequenceMethods.sq_slice to get "simple" slices like: myobj[x:y] It works perfectly, without p

Slices when extending python with C++

2011-12-27 Thread rozelak
Hallo, I have kind of special question when extening python with C++ implemented modules. I try to implement a class, behaving also like an array. And I need to implement slice-getters. I implemented PySequenceMethods.sq_slice to get "simple" slices like: myobj[x:y] It works perfectly, without p

Re: Exception Handling (C - extending python)

2011-10-25 Thread Stefan Behnel
Ulrich Eckhardt, 25.10.2011 08:49: Am 23.10.2011 14:41, schrieb Stefan Behnel: That's just fine. If you are interested in the inner mechanics of the CPython runtime, reading the source is a very good way to start getting involved with the project. However, many extension module authors don't ca

Re: Exception Handling (C - extending python)

2011-10-25 Thread Ulrich Eckhardt
Am 23.10.2011 14:41, schrieb Stefan Behnel: That's just fine. If you are interested in the inner mechanics of the CPython runtime, reading the source is a very good way to start getting involved with the project. However, many extension module authors don't care about these inner mechanics and j

Re: Exception Handling (C - extending python)

2011-10-23 Thread Lee
For a moment, back to the basics... I am using the example provided by docs at 2.1.2 "Providing finer control...". Using say: mynoddy = noddy2.Noddy() mynoddy.first = "a" mynoddy.last = 0 the last line causes an ugly crash (on python 2.6.5 on winxp). No way to catch the exception. As I understa

Re: Exception Handling (C - extending python)

2011-10-23 Thread Stefan Behnel
Hi, note that I reformatted your posting to get the replies back into order. Lee, 23.10.2011 13:32: On Oct 23, 10:06 pm, Stefan Behnel wrote: Lee, 23.10.2011 06:09: Where does PyExc_TypeError (and alike) points to? I can see its declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerr

Re: Exception Handling (C - extending python)

2011-10-23 Thread Christian Heimes
Am 23.10.2011 06:09, schrieb Lee: > Hi all, > > Where does PyExc_TypeError (and alike) points to? I can see its > declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h > but I cannot figure out what it is its value, where it is > initialized. It's initialized in Objects/exceptions

Re: Exception Handling (C - extending python)

2011-10-23 Thread Lee
Thanks Stefan, I am just interested to understand the mechanism inside python. If it points to an object that means I can defered it (through ob_type). >From there, how a function like PyErr_SetString knows what exception is? Where its value is kept? Lee On Oct 23, 10:06 pm, Stefan Behnel wro

Re: Exception Handling (C - extending python)

2011-10-23 Thread Stefan Behnel
Lee, 23.10.2011 06:09: Where does PyExc_TypeError (and alike) points to? I can see its declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h but I cannot figure out what it is its value, where it is initialized. It gets initialised inside of the interpreter core and then points

Exception Handling (C - extending python)

2011-10-22 Thread Lee
Hi all, Where does PyExc_TypeError (and alike) points to? I can see its declaration - PyAPI_DATA(PyObject *) PyExc_TypeError; - in pyerrors.h but I cannot figure out what it is its value, where it is initialized. Any help is greatly appreciated. Lee -- http://mail.python.org/mailman/listinfo/py

Re: Extending Python Questions .....

2009-02-26 Thread Nick Craig-Wood
Ben wrote: > On Feb 24, 11:31?am, Nick Craig-Wood wrote: > > So do you want to embed python into your code? > > > > I'm still not clear what you are trying to achieve with python, though > > I have a better idea what SLAG is now! > > Actually no, I want to EXTEND python using the lower levels

Re: Extending Python Questions .....

2009-02-25 Thread Ben
On Feb 24, 11:31 am, Nick Craig-Wood wrote: > Ben wrote: > >  No, It uses the the S-lang for video, and input control. However, SLAG > >  is more of an abstract layer on top of that. > > >  It has a Structures that contains menus and screens (menumodule / > >  screenmodule). One LOADS them up wit

Re: Extending Python Questions .....

2009-02-24 Thread Mike Driscoll
On Feb 24, 11:31 am, Nick Craig-Wood wrote: > Ben wrote: > >  No, It uses the the S-lang for video, and input control. However, SLAG > >  is more of an abstract layer on top of that. > > >  It has a Structures that contains menus and screens (menumodule / > >  screenmodule). One LOADS them up wit

Re: Extending Python Questions .....

2009-02-24 Thread Nick Craig-Wood
Ben wrote: > No, It uses the the S-lang for video, and input control. However, SLAG > is more of an abstract layer on top of that. > > It has a Structures that contains menus and screens (menumodule / > screenmodule). One LOADS them up with parameters. such as creating > a new menu is like:

Re: Extending Python Questions .....

2009-02-24 Thread Ben
On Feb 23, 2:31 pm, Nick Craig-Wood wrote: > Ben wrote: > >  In My S-Lag Project called, SLAG, I have some function keys that get > >  mapped back to S-lang internal functions. > > >  My SLAG project works pretty much like Python (as does the S-Lang). > >  You write a S-lang script > >  that "imp

Re: Extending Python Questions .....

2009-02-23 Thread Nick Craig-Wood
Ben wrote: > In My S-Lag Project called, SLAG, I have some function keys that get > mapped back to S-lang internal functions. > > My SLAG project works pretty much like Python (as does the S-Lang). > You write a S-lang script > that "imports" your extension. module - and all this gets run by

Re: Extending Python Questions .....

2009-02-23 Thread Diez B. Roggisch
Ben schrieb: Ok... Now I can start asking. In My S-Lag Project called, SLAG, I have some function keys that get mapped back to S-lang internal functions. My SLAG project works pretty much like Python (as does the S-Lang). You write a S-lang script that "imports" your extension. module - and all

Extending Python Questions .....

2009-02-23 Thread Ben
Ok... Now I can start asking. In My S-Lag Project called, SLAG, I have some function keys that get mapped back to S-lang internal functions. My SLAG project works pretty much like Python (as does the S-Lang). You write a S-lang script that "imports" your extension. module - and all this gets run

Re: Extending Python with C or C++

2009-01-09 Thread Nick Craig-Wood
Thomas Heller wrote: > Nick Craig-Wood schrieb: > > Thomas Heller wrote: > >> Nick Craig-Wood schrieb: > >> > Interesting - I didn't know about h2xml and xml2py before and I've > >> > done lots of ctypes wrapping! Something to help with the initial > >> > drudge work of converting the structur

Re: Extending Python with C or C++

2009-01-08 Thread Thomas Heller
Nick Craig-Wood schrieb: > Thomas Heller wrote: >> Nick Craig-Wood schrieb: >> > Interesting - I didn't know about h2xml and xml2py before and I've >> > done lots of ctypes wrapping! Something to help with the initial >> > drudge work of converting the structures would be very helpful. >> > >>

Re: Extending Python with C or C++

2009-01-07 Thread Nick Craig-Wood
Thomas Heller wrote: > Nick Craig-Wood schrieb: > > Interesting - I didn't know about h2xml and xml2py before and I've > > done lots of ctypes wrapping! Something to help with the initial > > drudge work of converting the structures would be very helpful. > > > > ( http://pypi.python.org/pypi/c

Re: Extending Python with C or C++

2009-01-07 Thread Thomas Heller
Nick Craig-Wood schrieb: > Ralf Schoenian wrote: >> Ryan wrote: >> > I've been using Python for many years now. It's a wonderful language >> > that I enjoy using everyday. I'm now interested in getting to know >> > more about the guts (C/C++)

Re: Extending Python with C or C++

2009-01-06 Thread sturlamolden
On Jan 5, 9:06 pm, Ryan wrote: > I've been using Python for many years now. It's a wonderful language > that I enjoy using everyday. I'm now interested in getting to know > more about the guts (C/C++) and extending it. But, extending python > still seems like a b

Re: Extending Python with C or C++

2009-01-06 Thread Nick Craig-Wood
Ralf Schoenian wrote: > Ryan wrote: > > I've been using Python for many years now. It's a wonderful language > > that I enjoy using everyday. I'm now interested in getting to know > > more about the guts (C/C++) and extending it. But, extending python > &

Re: Extending Python with C or C++

2009-01-06 Thread Stefan Behnel
Ryan wrote: > 3. Extending CPython by connecting it to Python-oblivious code written > in C with Ctypes (Ralf's suggestion is good for this) > 4. Extending CPython by connecting it to Python-aware (and specific) > code using the CPython C-API functions (http://docs.python.org/c-api/) For extending

Re: Extending Python with C or C++

2009-01-05 Thread Ryan
on the language include the object model, namespaces > (including modules), and the statement and infix-expression syntax. > > > (C/C++) and extending it. > > Now you are asking about CPython, the leading computer implementation. > > > But, extending python still seems lik

Re: Extending Python with C or C++

2009-01-05 Thread Terry Reedy
d the statement and infix-expression syntax. (C/C++) and extending it. Now you are asking about CPython, the leading computer implementation. But, extending python still seems like a black art to me. > Is there anymore docs or info on extending it besides the standard sparse ones (http://w

Re: Extending Python with C or C++

2009-01-05 Thread Ralf Schoenian
Ryan wrote: I've been using Python for many years now. It's a wonderful language that I enjoy using everyday. I'm now interested in getting to know more about the guts (C/C++) and extending it. But, extending python still seems like a black art to me. Is there anymore docs or in

Extending Python with C or C++

2009-01-05 Thread Ryan
I've been using Python for many years now. It's a wonderful language that I enjoy using everyday. I'm now interested in getting to know more about the guts (C/C++) and extending it. But, extending python still seems like a black art to me. Is there anymore docs or info on extending

Re: embedding and extending python C API registering callback handler objects

2008-06-27 Thread Tim Spens
--- On Fri, 6/27/08, Tim Spens <[EMAIL PROTECTED]> wrote: > From: Tim Spens <[EMAIL PROTECTED]> > Subject: Re: embedding and extending python C API registering callback > handler objects > To: python-list@python.org, "Matimus" <[EMAIL PROTECTED]>

Re: embedding and extending python C API registering callback handler objects

2008-06-27 Thread Tim Spens
thanks, but didn't fix the problem. --- On Fri, 6/27/08, Matimus <[EMAIL PROTECTED]> wrote: > From: Matimus <[EMAIL PROTECTED]> > Subject: Re: embedding and extending python C API registering callback > handler objects > To: python-list@python.org > Date: Fri

Re: embedding and extending python C API registering callback handler objects

2008-06-27 Thread Matimus
On Jun 27, 8:22 am, Tim Spens <[EMAIL PROTECTED]> wrote: > Hello all, > > I've been trying to get an example found > herehttp://codeidol.com/python/python3/Embedding-Python/Registering-Callb... > to work.  Every thing works fine except when I try to trigger an event from c > that will call a pyth

embedding and extending python C API registering callback handler objects

2008-06-27 Thread Tim Spens
Hello all, I've been trying to get an example found here http://codeidol.com/python/python3/Embedding-Python/Registering-Callback-Handler-Objects/ to work. Every thing works fine except when I try to trigger an event from c that will call a python function. Here is my test code: //-

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread John Machin
On Jun 20, 5:56 am, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED] nomine.org> wrote: > -On [20080619 17:11], Spectrum ([EMAIL PROTECTED]) wrote: > > > ImportError: dynamic module does not define init function > > Might be it's looking, but not finding, something like crti.S or the likes, > the

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread André Malo
* Jeroen Ruigrok van der Werven wrote: > -On [20080619 17:11], Spectrum ([EMAIL PROTECTED]) wrote: >> ImportError: dynamic module does not define init function > > Might be it's looking, but not finding, something like crti.S or the > likes, the C runtime files that specify stuff like _init and

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread Jeroen Ruigrok van der Werven
-On [20080619 17:11], Spectrum ([EMAIL PROTECTED]) wrote: > ImportError: dynamic module does not define init function Might be it's looking, but not finding, something like crti.S or the likes, the C runtime files that specify stuff like _init and _fini. -- Jeroen Ruigrok van der Werven / asmo

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread Spectrum
On Jun 19, 4:39 pm, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED] nomine.org> wrote: > -On [20080619 16:21], Spectrum ([EMAIL PROTECTED]) wrote: > > >          libmpi.so.0 => /usr/lib/openmpi/1.2.4-gcc/libmpi.so.0 > >(0x0042f000) > >          libopen-rte.so.0 => /usr/lib/openmpi/1.2.4-gcc/libope

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread Jeroen Ruigrok van der Werven
-On [20080619 16:21], Spectrum ([EMAIL PROTECTED]) wrote: > libmpi.so.0 => /usr/lib/openmpi/1.2.4-gcc/libmpi.so.0 >(0x0042f000) > libopen-rte.so.0 => /usr/lib/openmpi/1.2.4-gcc/libopen- >rte.so.0 (0x003d4000) > libopen-pal.so.0 => /usr/lib/openmpi/1.2.4-gcc/libopen- >pal.

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread Spectrum
On Jun 19, 2:10 pm, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED] nomine.org> wrote: > -On [20080619 13:53], Spectrum ([EMAIL PROTECTED]) wrote: > > >  ImportError: /big/School/Cluster/Opgave03/ctest.so: undefined > >symbol: ompi_mpi_comm_world > > [EMAIL PROTECTED] Opgave03]$ > > >  Can anyone

Re: Extending Python with C: Cannot find MPI library

2008-06-19 Thread Jeroen Ruigrok van der Werven
-On [20080619 13:53], Spectrum ([EMAIL PROTECTED]) wrote: > ImportError: /big/School/Cluster/Opgave03/ctest.so: undefined >symbol: ompi_mpi_comm_world > [EMAIL PROTECTED] Opgave03]$ > > Can anyone suggest anything? Can I get MPI to work in Python? Sounds like a typical case of not specifying an

Extending Python with C: Cannot find MPI library

2008-06-19 Thread Spectrum
I am writing some Python code using the Message Passing Interface (MPI), an API used in parallel computing. There exist a number of Python implementations of MPI, but apparently they all rely on the Numeric Python (numpy) package. I need to run my code on a particular machine made available by my

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Ivan Illarionov
On Wed, 04 Jun 2008 09:12:18 -0700, spectrumdt wrote: > Hello. > > I am trying to extend my Python program with some C code. > > This thread is sort of a follow-up to another thread of mine, linked > below. I don't know what the conventions are in this newsgroup about > creating new threads

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread spectrumdt
On Jun 4, 6:25 pm, Gerhard Häring <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > >   Hello. > > >   I am trying to extend my Python program with some C code. [...] > >   Anyway, my question is this: When compiling my C code to include in > > Python, using a Python script with the function

Re: Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread Gerhard Häring
[EMAIL PROTECTED] wrote: Hello. I am trying to extend my Python program with some C code. [...] Anyway, my question is this: When compiling my C code to include in Python, using a Python script with the function distutils.core.setup... can I choose which C compiler to use? On my system it

Extending Python with C: Can I specify another C compiler?

2008-06-04 Thread spectrumdt
Hello. I am trying to extend my Python program with some C code. This thread is sort of a follow-up to another thread of mine, linked below. I don't know what the conventions are in this newsgroup about creating new threads vs. staying in existing ones, but I figured I'd rather make a new o

Re: extending python with array functions

2008-02-05 Thread Janwillem
Gabriel Genellina wrote: > En Tue, 05 Feb 2008 05:28:33 -0200, Marc 'BlackJack' Rintsch > <[EMAIL PROTECTED]> escribi�: > >> On Mon, 04 Feb 2008 20:56:02 -0200, Gabriel Genellina wrote: >> >>> - the array module http://docs.python.org/lib/module-array.html provides >>> homogeneuos arrays that may

Re: extending python with array functions

2008-02-05 Thread Gabriel Genellina
En Tue, 05 Feb 2008 05:28:33 -0200, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> escribi�: > On Mon, 04 Feb 2008 20:56:02 -0200, Gabriel Genellina wrote: > >> - the array module http://docs.python.org/lib/module-array.html provides >> homogeneuos arrays that may be more efficient for your applic

Re: extending python with array functions

2008-02-04 Thread Marc 'BlackJack' Rintsch
On Mon, 04 Feb 2008 20:56:02 -0200, Gabriel Genellina wrote: > - the array module http://docs.python.org/lib/module-array.html provides > homogeneuos arrays that may be more efficient for your application. arrays > don't have a special API, you have to import the module and use its > functio

Re: extending python with array functions

2008-02-04 Thread Gabriel Genellina
En Mon, 04 Feb 2008 18:44:42 -0200, Janwillem <[EMAIL PROTECTED]> escribió: > I want to make numerical functions that can be called from python. > I am programming in pascal the last few decades so I had a look at > "python for delphi" (P4D). The demo09 gives as example add(a,b) using > integer

extending python with array functions

2008-02-04 Thread Janwillem
I want to make numerical functions that can be called from python. I am programming in pascal the last few decades so I had a look at "python for delphi" (P4D). The demo09 gives as example add(a,b) using integers and pyarg_parsetuple. That works! However, I cannot figure out what to do when a,

Re: extending Python - passing nested lists

2008-01-29 Thread Arnaud Delobelle
On Jan 29, 4:00 pm, Christian Meesters <[EMAIL PROTECTED]> wrote: > > You didn't mention speed in your original post. > > Sorry, perhaps I considered this self-evident - which it is, of course, not. > > > What about using > > array.array?  Unless I am mistaken, these are just a thin wrapper > > aro

Re: extending Python - passing nested lists

2008-01-29 Thread Mel
Christian Meesters wrote: >> You didn't mention speed in your original post. > Sorry, perhaps I considered this self-evident - which it is, of course, not. > >> What about using >> array.array? Unless I am mistaken, these are just a thin wrapper >> around normal C arrays. > The algorithm I want

Re: extending Python - passing nested lists

2008-01-29 Thread Christian Meesters
> You didn't mention speed in your original post. Sorry, perhaps I considered this self-evident - which it is, of course, not. > What about using > array.array? Unless I am mistaken, these are just a thin wrapper > around normal C arrays. The algorithm I want to implement requires several millio

Re: extending Python - passing nested lists

2008-01-29 Thread Arnaud Delobelle
On Jan 29, 1:22 pm, Christian Meesters <[EMAIL PROTECTED]> wrote: > Thanks. Point is that all such approaches would require lots(!) of calls to > the Python API - a way by which I won't gain the desired speed. You didn't mention speed in your original post. What about using array.array? Unless I

Re: extending Python - passing nested lists

2008-01-29 Thread Christian Meesters
Thanks. Point is that all such approaches would require lots(!) of calls to the Python API - a way by which I won't gain the desired speed. I've tried pyrex and the corresponding C-file is so convoluted with dummy variables, incrementing & decrementing references, and other stuff, that I want to

Re: extending Python - passing nested lists

2008-01-29 Thread Arnaud Delobelle
On Jan 29, 12:48 pm, Christian Meesters <[EMAIL PROTECTED]> wrote: > Think, that I'm still at the wrong track. Point is that I cannot find any > examples and don't know where to start here. > Perhaps my problem boils down to two questions: > I'd like to pass lists (in some cases nested ones) from P

Re: extending Python - passing nested lists

2008-01-29 Thread Christian Meesters
Think, that I'm still at the wrong track. Point is that I cannot find any examples and don't know where to start here. Perhaps my problem boils down to two questions: I'd like to pass lists (in some cases nested ones) from Python to C and convert those Python-lists to C-arrays (e. g. of doubles). M

Re: extending Python - passing nested lists

2008-01-28 Thread Christian Meesters
Mark Dickinson wrote: > Well, it's pretty clear: you misspelt "length" as "lenght". :) Well, that's not it ;-). (Damn copy & paste plague ...) > > PySequence_Fast doesn't return an array: it returns a PyObject---in > this case, a PyObject corresponding to a Python tuple. That's it. Thanks. Thi

Re: extending Python - passing nested lists

2008-01-28 Thread Mark Dickinson
On Jan 28, 10:10 am, Christian Meesters <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to write a C-extension function for an application of mine. For > this I need to pass a nested list (like: [[a, b, c], [d, e, f], ...], where > all letters are floats) to the C-function. Now, with the code I h

extending Python - passing nested lists

2008-01-28 Thread Christian Meesters
Hi, I would like to write a C-extension function for an application of mine. For this I need to pass a nested list (like: [[a, b, c], [d, e, f], ...], where all letters are floats) to the C-function. Now, with the code I have the compiler is complaining: "subscripted value is neither array nor poi

Re: Extending Python with C API

2007-10-18 Thread Sami Vaisanen
On Thu, 13 Sep 2007 21:26:33 -0400, Carsten Haese wrote: > On Thu, 2007-09-13 at 18:05 -0700, Thierry Masson wrote: >> Hello, >> >> I'm trying to use the C API to extend Python. I've looked at various >> books and web sites (including the docs at python.org) and I can't get >> any of the samples

Re: Extending Python with C API

2007-09-13 Thread Thierry Masson
On 9/13/07, Carsten Haese wrote: >Your module C code uses an unknown function by the name of PyBuildValue. >The actual name of the function you mean is Py_BuildValue. Thank you so much, Carsten. I can't believe I missed that underscore! I'm posting the working code below in case it ever turns out

Re: Extending Python with C API

2007-09-13 Thread Carsten Haese
On Thu, 2007-09-13 at 18:05 -0700, Thierry Masson wrote: > Hello, > > I'm trying to use the C API to extend Python. I've looked at various > books and web sites (including the docs at python.org) and I can't get > any of the samples to work. Below is a very minimalist example that > I'm trying to

Extending Python with C API

2007-09-13 Thread Thierry Masson
Hello, I'm trying to use the C API to extend Python. I've looked at various books and web sites (including the docs at python.org) and I can't get any of the samples to work. Below is a very minimalist example that I'm trying to get working and I was wondering if someone could tell me where I'm go

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Paul McGuire
On Aug 1, 8:08 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > > def add(self,other): > if len(self.contents) < self.capacity: > self.contents.append( other ) > else: > raise ValueError("can't add any more to this Box") > I guess that really should raise a

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Paul McGuire
On Aug 1, 3:10 pm, Maximus Decimus <[EMAIL PROTECTED]> wrote: > > Your code snippet was quite simple and it explained me very well than > the tutorial. HAts off to u!! > Thanks! > > I am doing my research in Pervasive space environments filled with > sensors and actuators. I am just trying to mo

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Maximus Decimus
On Aug 1, 9:08 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Jul 31, 3:28 pm, Maximus Decimus <[EMAIL PROTECTED]> wrote: > > > > > I am using python v2.5 and I am an amateur working on python. I am > > extending python for my research work and would like s

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Paul McGuire
On Jul 31, 3:28 pm, Maximus Decimus <[EMAIL PROTECTED]> wrote: > > I am using python v2.5 and I am an amateur working on python. I am > extending python for my research work and would like some help and > guidance w.r.t this matter from you experienced python developers. >

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Bjoern Schliessmann
Maximus Decimus wrote: > Since, I am an amateur in using python, | Most commonly an amateur is understood to be someone who does | something without pay or formal training. Conversely, a | professional is someone who has received training in a particular |

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Marc 'BlackJack' Rintsch
On Wed, 01 Aug 2007 01:42:38 +, Maximus Decimus wrote: > Since, I am an amateur in using python, could you please be more > specific. For new data types, you had asked to implement the classes. > I intend to use C for implementing these data types. So where do i > need to implement these class

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Ben Finney
Maximus Decimus <[EMAIL PROTECTED]> writes: > II want to add some more KEYWORDS Adding keywords can only be done by changing the parser for the Python compiler. You can download the source for your preferred implementation of Python (e.g. CPython) and change it there. But likely that's not the b

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Maximus Decimus
Since, I am an amateur in using python, could you please be more specific. For new data types, you had asked to implement the classes. I intend to use C for implementing these data types. So where do i need to implement these classes ie under which file or module in the python package. Thanks in a

Re: Extending Python by Adding Keywords & Data types

2007-07-31 Thread Marc 'BlackJack' Rintsch
On Tue, 31 Jul 2007 20:28:59 +, Maximus Decimus wrote: > II want to add some more KEYWORDS and DATATYPES into the python script > apart from the existing ones. New data types are easy: Just implement the classes. Why do you need new keywords? Can't the problem at hand be expressed in functi

Extending Python by Adding Keywords & Data types

2007-07-31 Thread Maximus Decimus
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced python developers. II want to add some more KEYWORDS and DATATYPES into the python script apart from the

Re: Embedding/Extending Python in/with C++: non-static members?

2007-07-19 Thread dmoore
thanks for the responses Nick and "AnonMail" > I'm doing a similar thing, and I would imagine others are also. > > 1. In a python file, set up wrapper functions that the python user > actually uses (e.g FunctionA). Each function corresponds to a > particular C/C++ extension function that you are

Re: Embedding/Extending Python in/with C++: non-static members?

2007-07-19 Thread [EMAIL PROTECTED]
On Jul 16, 9:45 am, dmoore <[EMAIL PROTECTED]> wrote: > Hi Folks: > > I have a question about the use of static members in Python/C > extensions. Take the simple example from the "Extending and Embedding > the Python Interpreter" docs: > > A simple module method: > > static PyObject * > spam_system

Re: Embedding/Extending Python in/with C++: non-static members?

2007-07-18 Thread [EMAIL PROTECTED]
On Jul 17, 12:24 pm, dmoore <[EMAIL PROTECTED]> wrote: > (I thought I'd follow up on this post so as not to send unsuspecting > readers down a hopeless path) > > duh! > > I've obviously spent too much time with dynamic languages. The problem > with what I'm trying to do is obvious: In C++ you simpl

Re: Embedding/Extending Python in/with C++: non-static members?

2007-07-17 Thread Nick Craig-Wood
dmoore <[EMAIL PROTECTED]> wrote: > I've obviously spent too much time with dynamic languages. The problem > with what I'm trying to do is obvious: In C++ you simply can't pass > pointers to call a particular instance of a C++ class method so there > is no way to initialize the PyMethodDef with

Re: Embedding/Extending Python in/with C++: non-static members?

2007-07-17 Thread dmoore
(I thought I'd follow up on this post so as not to send unsuspecting readers down a hopeless path) duh! I've obviously spent too much time with dynamic languages. The problem with what I'm trying to do is obvious: In C++ you simply can't pass pointers to call a particular instance of a C++ class

Embedding/Extending Python in/with C++: non-static members?

2007-07-16 Thread dmoore
Hi Folks: I have a question about the use of static members in Python/C extensions. Take the simple example from the "Extending and Embedding the Python Interpreter" docs: A simple module method: static PyObject * spam_system(PyObject *self, PyObject *args) { ... } listed in a method table: s

Re: Embedded and extending python 2.5: trouble with __main__ in PyRun_SimpleFileExFlags?

2007-03-04 Thread Carl Douglas
I am going to answer this question myself, but perhaps this will be useful for someone else. My original C++ code was fine, the PyRun_SimpleFile was failing due to errors in my python code. To get a console and display the python interpreter errors I allocated a console, and redirected stdout and

Embedded and extending python 2.5: trouble with __main__ in PyRun_SimpleFileExFlags?

2007-02-19 Thread Carl Douglas
Hi Python fans, I am developing a DLL that is loaded by a host application on windows. I'm using python 2.5. My DLL uses an embedded python interpreter which can access the host application through an API which I have exposed using SWIG 1.3.31. Therefore I have both extended and embedded Python

Re: return tuple from C to python (extending python)

2006-10-26 Thread Kiran
Farshid Lashkari wrote: > Simon Forman wrote: > > I have not done a great deal of extension work with python, however, I > > do not believe you can simply cast an int (or pointer to int, which is > > what you say dat is declared as, unless my C is /really/ rusty) to > > PyObject*. > > > > I think

Re: return tuple from C to python (extending python)

2006-10-24 Thread Andrew Poelstra
On Tue, 2006-10-24 at 15:24 -0700, Kiran wrote: > Hi all, I want to make python call some C functions, process them and > return them. Try comp.lang.python -- Andrew Poelstra -- http://mail.python.org/mailman/listinfo/python-list

Re: return tuple from C to python (extending python)

2006-10-24 Thread Chetan
"Kiran" <[EMAIL PROTECTED]> writes: > PyObject* toRet; > toRet = PyTuple_New(num_addr); > > then, in a for loop, i assign values to the tuple as follows: > > for ( i = 0; i < num_addr; i++ ) > { > printf("%d\n", dat[i]); > PyTuple_SET_ITEM(toRet, i, (PyObject*)dat[i] ); > }

Re: return tuple from C to python (extending python)

2006-10-24 Thread Farshid Lashkari
Simon Forman wrote: > I have not done a great deal of extension work with python, however, I > do not believe you can simply cast an int (or pointer to int, which is > what you say dat is declared as, unless my C is /really/ rusty) to > PyObject*. > > I think you need to do something like Py_Build

Re: return tuple from C to python (extending python)

2006-10-24 Thread Simon Forman
Kiran wrote: > Hi all, I want to make python call some C functions, process them and > return them. > > Ok, I got all the wrapper functions and everything setup right. Here > is my problem. What I need to do is to return a tuple from C to > python. > > To go about doing this, I first create a tup

return tuple from C to python (extending python)

2006-10-24 Thread Kiran
Hi all, I want to make python call some C functions, process them and return them. Ok, I got all the wrapper functions and everything setup right. Here is my problem. What I need to do is to return a tuple from C to python. To go about doing this, I first create a tuple object in C doing the fo

Re: beginner questions on embedding/extending python with C++

2006-08-09 Thread Hoop
Hi All, I am in the process also of trying to call Python script from a C++ windows app. I have looked at the Boost site and am currently reading over the Embedding portion of the tutorial. A question I have is that there appear to be about 4 or 5 Boost items avaiable for download. Which one should

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Qun Cao
Thanks for all the good pointers! I am still reading throught them, but Boost seems to be the way to go! Roman Yakovenko wrote: > On 8 Aug 2006 02:28:31 -0700, Qun Cao <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > > > I am a beginner on cross language development. My problem at hand is to > > bu

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Qun Cao
Thanks Diez, It is a good relief that I only need to wrap the classes I need. I decide to try Boost first because it seems to have a wider audience than SIP, but I would definately look into SIP if I want to do Qt development in the future. Diez B. Roggisch wrote: > > Since the main program is s

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Ben Sizer
Qun Cao wrote: > Hi Everyone, > > I am a beginner on cross language development. My problem at hand is to > build a python interface for a C++ application built on top of a 3D > game engine. The purpose of this python interface is providing a > convenient scripting toolkit for the application. As

Re: beginner questions on embedding/extending python with C++

2006-08-08 Thread Roman Yakovenko
On 8 Aug 2006 02:28:31 -0700, Qun Cao <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > I am a beginner on cross language development. My problem at hand is to > build a python interface for a C++ application built on top of a 3D > game engine. The purpose of this python interface is providing a > con

  1   2   >