Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43849

Re: equivalent to C pointer

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drobinow@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'think,': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'main()': 0.09; 'pointers': 0.09; 'received:209.85.219': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '###': 0.16; '0.1)': 0.16; 'ideal.': 0.16; 'left,': 0.16; 'main():': 0.16; 'pointers.': 0.16; '{0}': 0.16; 'wrote:': 0.18; '&lt;': 0.19; 'thu,': 0.19; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'math': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'alone': 0.33; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'received:209': 0.37; 'step': 0.37; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:& 20': 0.39; 'sure': 0.39; 'skip:u 10': 0.60; 'skip:\xc2 10': 0.60; 'save': 0.62; 'to:addr:gmail.com': 0.65; '8bit%:100': 0.72; 'power': 0.76; '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=5YXc2uT3i1u2XamfsOxZpaifFWEWhFAeCB2x0H0oW38=; b=Oyu3Y+Q9Bz/QYWXGqcJIJDMSkxyWtCkS4mE3UZ1+eoTRMRpjcqJa4k4h2HeHneZV+v AMGIz2GhmuznFKfp2OkjrkaX4+nIjRxKI69NcqrofBfQyaFJGcq7RsMIyfNqPsFDVrUr ol5JZoXvM9TuRCTvqyQy7jneoOeHRxANy8sEcA+N+OQxnR0mdyMZC6HWPbM7XjLtTpu3 Su7WLby7AAuniTZL/G8fYk3XU8Lm69BzabcvgmeOyzGusKCBunmRrKLHn9Alb4gjxLQl rraGRcYjRGBrUOb89BSgNA353CB1XPCuHcasvq4ObOwmkWFVw+L9B6SJ+Qc8CmS37cUj Yu0w==
MIME-Version 1.0
X-Received by 10.182.96.135 with SMTP id ds7mr5010693obb.45.1366308892921; Thu, 18 Apr 2013 11:14:52 -0700 (PDT)
In-Reply-To <CAF3f0sTgxWupYqKDdtqqaPBz2kCZ04404rtDBnsOkDLXAfbQpQ@mail.gmail.com>
References <CAF3f0sQ_rsdKwaEOCmFHEeEwpVUaNUo-pOYgoqYA_F-k0CftcA@mail.gmail.com> <51702AB6.30609@gmail.com> <CAF3f0sTgxWupYqKDdtqqaPBz2kCZ04404rtDBnsOkDLXAfbQpQ@mail.gmail.com>
Date Thu, 18 Apr 2013 14:14:52 -0400
Subject Re: equivalent to C pointer
From David Robinow <drobinow@gmail.com>
To abdelkader belahcene <abelahcene@gmail.com>
Content-Type multipart/alternative; boundary=047d7b2e4d5e38f0ea04daa69451
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.786.1366308903.3114.python-list@python.org> (permalink)
Lines 86
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366308903 news.xs4all.nl 2223 [2001:888:2000:d::a6]:34693
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43849

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Apr 18, 2013 at 1:50 PM, abdelkader belahcene
<abelahcene@gmail.com>wrote:

> 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
>
You don't need C pointers.  The design below is demonstrative, not ideal.

# file  MyFuncs.py
def F1(x):
    return x*x

def Trapeze(f, left, right, step):
    X0 = left
    Z = 0.0
    while (X0 < right):
        X1 = X0 + step
        Y1 = f(X1)
        Y0 = f(X0)
        Z += (Y1 + Y0) * step * 0.5
        X0 = X1
    return Z



# file UseMyFuncs.py
import math
import MyFuncs

def main():
    y = MyFuncs.Trapeze(math.sin, -2.5, 3.2, 0.1)
    print("Value for sin is:{0} ".format(y))
    y = MyFuncs.Trapeze(MyFuncs.F1, 0, 3, 0.1)
    print("Value for F1 is {0} ".format(y))

if __name__ == "__main__":
    main()

###
#python3 UseMyFuncs.py
###

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: equivalent to C pointer David Robinow <drobinow@gmail.com> - 2013-04-18 14:14 -0400

csiph-web