<div dir="ltr"><div>Thanks a lot, I think this does the task<br><br></div>cheers<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 7:14 PM, David Robinow <span dir="ltr"><<a href="mailto:drobinow@gmail.com" target="_blank">drobinow@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 class="im"><div class="gmail_quote">On Thu, Apr 18, 2013 at 1:50 PM, 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>Thanks for answer,  <br>but with C  we can compile the trapeze function and put it in librairy,  <br></div>If we try to save the trapeze alone in  package to import it later,  I think, I am not sure<br>


</div>it will be refused because F1 and sin are not define !!!     this is the power of the C pointers !!!<br></div>the link is dynamic<br></div></div></blockquote></div></div>You don't need C pointers.  The design below is demonstrative, not ideal.<br>

<br># file  MyFuncs.py<div class="im"><br>def F1(x):<br>    return x*x<br><br>def Trapeze(f, left, right, step):<br>    X0 = left<br>    Z = 0.0<br>    while (X0 < right):<br></div><div class="im">        X1 = X0 + step<br>
</div>        Y1 = f(X1)<br>        Y0 = f(X0)<div class="im"><br>
        Z += (Y1 + Y0) * step * 0.5<br></div><div class="im">        X0 = X1<br>    return Z<br><br><br><br></div># file UseMyFuncs.py<br>import math<br>import MyFuncs<br><br>def main():<br>    y = MyFuncs.Trapeze(math.sin, -2.5, 3.2, 0.1)<div class="im">
<br>    print("Value for sin is:{0} ".format(y))<br></div>
    y = MyFuncs.Trapeze(MyFuncs.F1, 0, 3, 0.1)<div class="im"><br>    print("Value for F1 is {0} ".format(y))<br><br>if __name__ == "__main__":<br>    main()<br><br></div>###<br>#python3 UseMyFuncs.py<br>
###<br><br>
</blockquote></div><br></div>