<div dir="ltr">While Python does not have pointers, Python functions are objects, and they may be passed like any other object:<div><br></div><div>def F1(x):</div><div style>    return x * x</div><div style><br></div><div style>

def Trapeze(Fonc, left, right, step):</div><div style>    ...code...</div><div style>    Y1 = Fonc(X1)</div><div style>    ...code...</div><div style><br></div><div style>def main():</div><div style>   ...code...</div><div style>

   y = Trapeze(F1, -2.5, 3.2, 0.1)</div><div style>   ...code...</div><div style><br></div></div><div class="gmail_extra"><br clear="all"><div>Chris</div>
<br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 10:06 AM, abdelkader belahcene <span dir="ltr"><<a href="mailto:abelahcene@gmail.com" target="_blank">abelahcene@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div><div><div><div><div><div><div>Hi everybody,  <br><br></div>I am new to python  and I am discovering it.<br></div>I know C well,<br></div>and want to know if python knows how to manage Pointers<br></div>


like pointer to function  here is a C example how to write it in python<br></div><div>Intergration with trapeze method<br></div><div><br></div>When we write Trapeze   ( at the compilation level) we don't know which functions <br>


</div>Fonc  to handle.      Here for example we use  sin and a user defined  F1<br></div>The program is attached too<br><div><br><div><div><div><div><div><div><div><div><div>#include <stdio.h><br>#include <math.h><br>


 <br>double F1 (double x){ <br>        return x*x; <br>}<br>double Trapeze(double Fonc(double ), <br>                                double left, double right, double step){<br>  double X1, X0, Y0, Y1, Z = 0;    <br>  for(X0=left; X0 < right ; X0 = X0 + step) {<br>


    X1 = X0 + step;<br>    Y1 = Fonc(X1);    Y0 = Fonc(X0);<br>    Z  += (Y1 + Y0) * step * 0.5;<br>  }<br>   return Z;<br>}<br>int  main(){ <br>  double y;<br>  y=Trapeze(sin, -2.5, 3.2, 0.1);<br>  printf("\n\tValue for sin  is : \t %8.3lf ", y);<br>


  y=Trapeze(F1, 0, 3, 0.1);<br>  printf("\n\tValue for F1 is : \t %8.3lf ", y);<br>  return 0;<br>} <br>/**<br>    Value for sin  is :         0.197 <br>    Value for F1 is :          9.005<br>    */<br></div><div>


thanks a lot<br></div></div></div></div></div></div></div></div></div></div></div>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br></div>