From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ad4:476b:: with SMTP id d11mr4784820qvx.57.1607081874255; Fri, 04 Dec 2020 03:37:54 -0800 (PST) X-Received: by 2002:a37:bac7:: with SMTP id k190mr8252519qkf.464.1607081874056; Fri, 04 Dec 2020 03:37:54 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 4 Dec 2020 03:37:53 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=124.149.31.79; posting-account=d51RWwoAAADvR-x0zYAtT9z3CRxT1eXo NNTP-Posting-Host: 124.149.31.79 References: <7223f058-c593-4905-b9ba-0a5cb3e64de2n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Import Python library into an Ada package? From: Roger Mc Injection-Date: Fri, 04 Dec 2020 11:37:54 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60695 List-Id: On Friday, December 4, 2020 at 9:23:23 PM UTC+11, Dmitry A. Kazakov wrote: > On 2020-12-04 08:36, Roger Mc wrote:=20 > > Is it possible to import a Python library, such as graphviz, into an Ad= a package?=20 > > So far I have only been able to find information on exporting Ada to Py= thon. > I am not sure what you mean. Python is not a compiled language, so=20 > formally speaking a Python library is not a library and you cannot=20 > import it in the sense of linking it to your application and calling=20 > subprograms from it using certain calling conventions.=20 >=20 > If you rather meant whether you could execute a Python script from Ada=20 > while passing parameters to it and taking results from, yes you can. If= =20 > that script were a part of some Python module, yes you can load it and=20 > once loaded call (interpret) functions from the module.=20 >=20 > P.S. Before you proceed, Python is a huge mess and interfacing it is a=20 > pain in the ... So you should consider if Graphviz worths the efforts.=20 > If you find a GTK or Qt library that doing approximately same, that=20 > would be a wiser choice, IMO.=20 >=20 > --=20 > Regards,=20 > Dmitry A. Kazakov=20 > http://www.dmitry-kazakov.de Many thanks for your prompt response and comments Dmitry; they are well app= reciated with some of the contents somewhat expected. I think that I misused the term " Python library"; I think "Python module" = is what I should have used. In this context, in Python, is a module a script? I'll investigate this. So I need to see if I can "can load it and once loaded call (interpret) fu= nctions from the module". This seems to the approach that I need to try.=20 Your comment regarding Graphviz was expected. I used it as an example to pr= ovide context and certainly do not intend to actually use it for needed gra= phics. My plan is to use GTK or write my own Ada code for simpler graphics. The project that I am embarking on is to use Ada for an on-line course in m= achine learning that uses Python as its teaching platform.=20 The importing that I was contemplating concerns special machine learning Py= thon modules used in the course. Of course, the alternative is for me to translate the Python modules into A= da which is something I've done in the past; generally, in my opinion, yiel= ding much better and more readable code. Again, thanks for your very helpful comments which, hopefully, have focused= my mind on the way ahead. Regarding your comment that "Python is a huge mess" and my own opinion of P= ython; I am mortified that Python seems to have become the standard languag= e for teaching computer programming and, particularly, that it seems to be = the choice of leading university computer science courses. It seems that the old well-established rules of quality computer program de= sign have been completely abandoned by these institutions. Best regards, Roger Mc Murtrie