Python interface with SWI-Prolog - python

I want to use a Python script as a frontend to a Prolog program that uses the SWI-PL engine.
So, the components of the setup are:
Python (2.7 or higher)
SWI-PL: website here
I've been looking around for an interface between SWI-PL and Python.
What I found are:
PySwip but it seems to be lacking from what i see from old questions here, and also seems unsupported.
PyLog, which seems newer but also has some activity. Although i don't know how good it is.
What is the recommended way of using Python to communicate with SWI-prolog?
Are there perhaps other ways to accomplish this?
Maybe with another prolog engine?
I'm stuck with the Prolog language and Python because I know them best, so that would be necessary (I know for instance there are also tools for Java).

I've personally used PySWIP successfully. Here's a link to a project I did for my AI class in university in which I used PySWIP.
I think the difference is that PySWIP is a bridge (just send queries to a Prolog database and get responses) whereas PyLog seems to be an implementation of Prolog (or a built-in Prolog engine) in Python, with abstractions on Prolog code using objects.
I have no particular recommendation for you. Choose whichever you deem will suit your project best. Consider the licenses under which these libraries are published if you will need to worry about your code's license.

Related

Is there a python equivalent to Laravel 4?

Laravel 4 enables me to develop both small scale and enterprise scale app's easily and efficiently, and its modular concepts allow me to extend it core, build custom reusable packages, and easily follow TDD practices.
I have been diving into the wonderful world of python (v3) and wondered what the equivalent web framework would be in the python community? A framework that follows some of the same core concepts built into Laravel 4 such as MVC design pattern, easy testing, modular design, packages etc.
Yes. Pyramid is what you are looking for. It's written from the ground up to be based in common Python libraries and components, and you can swap out pieces for other pieces as you wish. Python as a language is geared for TDD, and Pyramid takes advantage of that. You can push your own libraries, if they are abstract enough, out to PyPi for yourself, if you wish, but you can of course just keep them within your own projects too.
There are other Python frameworks, but if you're looking for modular and extensible, without a whole lot of framework interference in your working style preference, Pyramid is the way to go.
P.S. this question is better suited for programmers.stackexchange.com.
Python also has a web framework called Masonite which is a lot like Laravel. Heavily inspired by Laravel and a lot of Laravel developers can pick it up really easily.
Also has an ORM called Masonite ORM which is heavily inspired by eloquent
You can look at the framework I'm currently building, namely glim. There exists inspiration from play framework & laravel in it. You can get more information from the docs page.
It also has an extension system where developers can integrate to it.
You can look at the extensions I have built;

Can I call external *python* functions from google refine?

I'm investigating Google refine to speed up some of my data work -- never used it before this week, but I like a lot of what I see.
My biggest question so far is whether it's possible to call external python functions from Refine. I know you can call jython internally, but that doesn't provide access to C-based python libraries (e.g. lxml), and I have scripts elsewhere that I'd like to integrate, without lots of copy-paste or rewrite hassle.
What options are there for doing this in Refine? I'm willing to get creative -- I just want a stable, re-usable solution.
As Google Refine Wiki says:
lxml will NOT work in Jython, since lxml has C bindings for CPython (regular Python), hence will not work in Refine which is Jython / Java only, and has no CPython interpreter built-in
But you can try Google Refine Python Client Library to create projects and manipulate your data programmatically.
I'm going to mark reclosedev's answer as accepted, but there's still a litle more to the story.
The other answer to this question is that you can set up your own python-based API. For this project, I was able to set up a django app running on a local server. It only took an hour or so to build the API to my existing library.
More hassle than I'd have liked, but it fit the bill for this project without soaking up too much time.

Python or WPF reporting application

I have an existing VS-2008 Windows application with back-end MySQL Server 5.5. The existing application uses Crystal Reports for reporting. I want to get rid of Crystal Reports and want to use another tool that seamlessly integrates with VS-2010 Express. I want to remove reporting options from my existing application and want to write a new WPF reporting application using VS-2010 Express. I want a free tool but as I am using MySQL, tools like SSRS are not useful for me.
What are the options? I am planning the other way round by writing a Python reporting application powered by any open-source Python reporting tool.
For WPF you can use http://wpfreports.codeplex.com/ for simple reports or follow this article instructions to make you own: http://janrep.blog.codeplant.net/post/WPF-Multipage-Reports-Part-I.aspx
I've used SSRS, but only the RDLC part (you can use it with any datasource), but not very happy with the results and WPF does not have a native RDLC ReportViewer.
Also check this related question What's the best approach to printing/reporting from WPF?
Why not have both? IronPython is a python implementation on top of .NET. It allows you to write code that is totally python, but gives you access to all of .NET, including WPF.
For a quick look at what this looks like, here is a basic WPF project using ironpython.

Python equivalent to Java's JNLP Web Start?

Is there any way to achieve the same functionality in Python, i.e., launching a script from a browser and automatically updating it from a central server location?
Run your app on Jython and use Java Web Start?
From a comment below, http://blog.pyproject.ninja/posts/2016-03-31-web-start-on-jython.html, provides a complete example.
Note that Jython is not Python- some stuff does not work, and notably Jython is only Python-2.7 compatible.
Well this is still not a full match of the features of JNLP but maybe esky is closer to what you want. It's not browser based but once your app is installed on the client it can update itself. It might also lack something in the cross-platform department so depending on your environment YMMV.
Another alternative might be the Dabo framework at dabodev.com. It's been a few years since i looked at that but it still looks like it's alive :-)
You may be able to achieve some functionality with Skulpt although it uses classless python, so its functionality is rather limited.
Well check out this python wiki page as it lays out various options.

Other than basic python syntax, what other key areas should I learn to get a website live?

Other than basic python syntax, what other key areas should I learn to get a website live?
Is there a web.config in the python world?
Which libraries handle things like authentication? or is that all done manually via session cookies and database tables?
Are there any web specific libraries?
Edit: sorry!
I am well versed in asp.net, I want to branch out and learn Python, hence this question (sorry, terrible start to this question I know).
Basic Python syntax isn't half of what you need to know.
All of the Python built-in data structures.
Object-oriented design.
What python module and packages are.
The Python libraries -- almost everything you could ever want has already been written.
To name a few things.
If you've done some web development, you probably have some background in HTTP protocol, HTML, .CSS and Javascript and SQL.
You should use a framework to handle the endless collection of mundane details, like authentication. Look at Django.
Answer replaced to correspond with the updated question.
If you're already familiar with ASP.NET, the easiest way to jump into creating a website with Python is probably to look into one of the major web frameworks. Django is very popular, working through the installation guide and the tutorial will probably get you rolling pretty well.
Really though, I'd personally suggest at least learning the language itself to a basic competency level before trying to dive right into using it inside a web framework. I think you'll be trying to force yourself to learn too much at once. In terms of just learning Python, the free book Dive Into Python is always spoken of highly.
Oh, golly.
Look, this is gonna be real hard to answer because, read as you wrote it, you're missing a lot of steps. Like, you need a web server, a design, some HTML, and so on.
Are you building from the ground up? Asking about Python makes me suspect you may be using something like Zope.
Don't forget to give IronPython a try - your .NET experience can help making sense of newly learned Python idioms.
IronPython is an implementation of the Python programming language running under .NET and Silverlight. It supports an interactive console with fully dynamic compilation. It's well integrated with the rest of the .NET Framework and makes all .NET libraries easily available to Python programmers, while maintaining compatibility with the Python language.
Of course the builtins. And become familiar with the standard library (until you start to remember what's in it, I'd suggest looking through it any time you're about to implement something... It might be there already!)
You'll want some kind of framework, I'd recommend Django or TurboGears
But you also need to learn the pythonic-way. For this, open up a Python interpreter and type:
import this

Categories