From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.17.174 with SMTP id v43mr3376401otf.141.1476950224857; Thu, 20 Oct 2016 00:57:04 -0700 (PDT) X-Received: by 10.157.43.193 with SMTP id u59mr1649308ota.16.1476950224828; Thu, 20 Oct 2016 00:57:04 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!66no692124itl.0!news-out.google.com!w143ni1496itb.0!nntp.google.com!e187no683414itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 20 Oct 2016 00:57:04 -0700 (PDT) In-Reply-To: <9f771768-9d3e-43a1-b2e7-048851f5b4f9@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:2ab8:224:1:1f8:7fc8:c4d3:6c64; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH NNTP-Posting-Host: 2a02:2ab8:224:1:1f8:7fc8:c4d3:6c64 References: <9f771768-9d3e-43a1-b2e7-048851f5b4f9@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <174e458e-70b8-411b-b1aa-b888838145d1@googlegroups.com> Subject: Re: Where to find good/simple examples for gnatcoll (python)? From: briot.emmanuel@gmail.com Injection-Date: Thu, 20 Oct 2016 07:57:04 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:32144 Date: 2016-10-20T00:57:04-07:00 List-Id: If you only want to execute a python script (and perhaps get the output as a string), you could try: Python : constant Scripting_Language := Lookup_Scripting_Language (Repo, "python"); GNATCOLL.Scripts.Execute_Command (Python, "2 + 3"); Now, if you want to get the result, this is a little more complicated. Assuming you want to call a foo() function in python, you have to prepare an object with the arguments, and that will receive the return value. Data : Callback_Data'Class := Create (Python, 0); Result : Integer; Data.Execute_Expression ("2+3"); -- newer versions of gnatcoll Result := Data.Return_Value; or Data : Callback_Data'Class := Create (Python, 2); Result : Integer; Data.Set_Nth_Arg (1, 2); Data.Set_Nth_Arg (2, 3); Data.Execute_Command ("foo"); -- newer versions of gnatcoll Result := Data.Return_Value;