Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'everybody,': 0.07; 'think,': 0.07; '#include': 0.09; 'closest': 0.09; 'pointers': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'cheers': 0.12; '/**': 0.16; '0.1);': 0.16; '0.5;': 0.16; 'iterators': 0.16; 'left,': 0.16; 'x1,': 0.16; 'y1,': 0.16; 'wrote:': 0.18; '<': 0.19; 'thu,': 0.19; 'example': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'compilation': 0.24; 'pointer': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'define': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'alone': 0.33; 'knows': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'functions.': 0.36; 'method': 0.36; 'thanks': 0.36; 'too': 0.37; 'step': 0.37; 'skip:& 10': 0.38; 'pm,': 0.38; '\xa0\xa0\xa0': 0.39; 'sure': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'new': 0.61; 'save': 0.62; 'such': 0.63; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'power': 0.76; 'use\xa0': 0.84; 'discovering': 0.91; 'notion': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=tM7bGkMhi6UeqGDbWdknO0bkrL2W1RHtko0CO1ANjNM=; b=aNPe84LsDs/qyLvbXQhOEYGTmB2MyZfU9wuIQy3/EbQknfqW0iYzm0xkO7yRl8EtrV HAeBHUaznN8Xx5B66vQQa6oLqiBQy0cix44cFhUSNnZpafTjHnfe8ofD9YLQvyGRHFeO ajXnaALln8z6n6KEdatg+jpXjOqXWtSPkjme8M/6JM+VKsKnkYN7hoziTak8dO5vmwef 7pJO9zTq3osXL9rsNpgmthDjOFDtwMIJ2XfTK/vIRml3gjIw6v+Zbx85tR1mI8NKr0x7 HA6r7bC4lPhgssCxjHxX60ra+IDYN1QZKK3DVvXScKdIYHgKfgXfVqMKoI9zSUgRP0E4 zAuA== MIME-Version: 1.0 X-Received: by 10.182.125.132 with SMTP id mq4mr6034088obb.79.1366307400197; Thu, 18 Apr 2013 10:50:00 -0700 (PDT) In-Reply-To: <51702AB6.30609@gmail.com> References: <51702AB6.30609@gmail.com> Date: Thu, 18 Apr 2013 18:50:00 +0100 Subject: Re: equivalent to C pointer From: abdelkader belahcene To: Karim Content-Type: multipart/alternative; boundary=089e013a1ede3e306804daa63bac Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 214 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366307409 news.xs4all.nl 2230 [2001:888:2000:d::a6]:46258 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43844 --089e013a1ede3e306804daa63bac Content-Type: text/plain; charset=ISO-8859-1 Thanks for answer, but with C we can compile the trapeze function and put it in librairy, If we try to save the trapeze alone in package to import it later, I think, I am not sure it will be refused because F1 and sin are not define !!! this is the power of the C pointers !!! the link is dynamic thanks On Thu, Apr 18, 2013 at 6:17 PM, Karim wrote: > > Hello, > > There is no such notion in python. > But the closest are iterators and generator functions. > > Cheers > Karim > > > On 18/04/2013 19:06, abdelkader belahcene wrote: > > Hi everybody, > > I am new to python and I am discovering it. > I know C well, > and want to know if python knows how to manage Pointers > like pointer to function here is a C example how to write it in python > Intergration with trapeze method > > When we write Trapeze ( at the compilation level) we don't know which > functions > Fonc to handle. Here for example we use sin and a user defined F1 > The program is attached too > > #include > #include > > double F1 (double x){ > return x*x; > } > double Trapeze(double Fonc(double ), > double left, double right, double step){ > double X1, X0, Y0, Y1, Z = 0; > for(X0=left; X0 < right ; X0 = X0 + step) { > X1 = X0 + step; > Y1 = Fonc(X1); Y0 = Fonc(X0); > Z += (Y1 + Y0) * step * 0.5; > } > return Z; > } > int main(){ > double y; > y=Trapeze(sin, -2.5, 3.2, 0.1); > printf("\n\tValue for sin is : \t %8.3lf ", y); > y=Trapeze(F1, 0, 3, 0.1); > printf("\n\tValue for F1 is : \t %8.3lf ", y); > return 0; > } > /** > Value for sin is : 0.197 > Value for F1 is : 9.005 > */ > thanks a lot > > > > --089e013a1ede3e306804daa63bac Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks for answer,=A0
but with C= =A0 we can compile the trapeze function and put it in librairy,=A0
If we try to save the trapeze alone in=A0 package to import it later,=A0 = I think, I am not sure
it will be refused because F1 and sin are not define !!!=A0=A0=A0=A0 = this is the power of the C pointers !!!
the link is dynamic
thanks



On Thu, Apr 18, 2013 at 6:17 PM, Karim <= span dir=3D"ltr"><kliateni@gmail.com> wrote:

Hello,

There is no such notion in python.
But the closest are iterators and generator functions.

Cheers
Karim


On 18/04/2013 19:06, abdelkader belahcene wrote:
Hi everybody,=A0

I am new to python=A0 and I am discovering it.
I know C well,
and want to know if python knows how to manage Pointers
like pointer to function=A0 here is a C example how to write it in python
Intergration with trapeze method

When we write Trapeze =A0 ( at the compilation level) we don= 9;t know which functions
Fonc=A0 to handle.=A0=A0=A0=A0=A0 Here for example we use=A0 sin = and a user defined=A0 F1
The program is attached too

#include <stdio.h>
#include <math.h>
=A0
double F1 (double x){
=A0=A0=A0 =A0=A0=A0 return x*x;
}
double Trapeze(double Fonc(double ),
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 double left, double right, double step){
=A0 double X1, X0, Y0, Y1, Z =3D 0;=A0=A0=A0 =A0 for(X0=3Dleft; X0 < right ; X0 =3D X0 + step) {
=A0=A0=A0 X1 =3D X0 + step;
=A0=A0=A0 Y1 =3D Fonc(X1);=A0=A0=A0 Y0 =3D Fonc= (X0);
=A0=A0=A0 Z=A0 +=3D (Y1 + Y0) * step * 0.5;
=A0 }
=A0=A0 return Z;
}
int=A0 main(){
=A0 double y;
=A0 y=3DTrapeze(sin, -2.5, 3.2, 0.1);
=A0 printf("\n\tValue for sin=A0 is : \t %= 8.3lf ", y);
=A0 y=3DTrapeze(F1, 0, 3, 0.1);
=A0 printf("\n\tValue for F1 is : \t %8.3l= f ", y);
=A0 return 0;
}
/**
=A0=A0=A0 Value for sin=A0 is : =A0=A0=A0 =A0= =A0=A0 0.197
=A0=A0=A0 Value for F1 is : =A0=A0=A0 =A0=A0=A0= =A0 9.005
=A0=A0=A0 */
thanks a lot




--089e013a1ede3e306804daa63bac--