My GSoC’2013 project for development a python backend for Cantor reach some objectives in before weeks.
Firstly I developed preliminary versions of syntax highlighting and tab complete features. This version use XML file processing to provide a basic set of keywords and built-in functions to these features. To activate tab complete, press Tab button after some letter. You can see some screenshots of these features below (click mouse right-button and enlarge it):
A simple syntax highlighting
More syntax highlighting and tab complete
Next, the preliminary version of the backend developed during LaKademy was build to support python script mode. But it would be more interesting to support python interactive mode in Cantor console. So, to do it, I implemented preprocessing in python command before send it to python interpreter, adding some commands to simulate python interactive mode.
This solution use PyRun_SimpleString from python/C API to process python commands in python script mode. There is other functions from python/C API to process python commands in interactive mode, for example, PyRun_InteractiveOne, but this function requires the python commands in a file to process and the output of commands is a bit of hard to get. So, for now, PyRun_SimpleString + preprocessing commands is working very well.
You can see in screenshots below and above that variable values and operation values are show in Cantor console without use of print command. It is a one of characteristic of python interactive mode:
More examples of syntax highlighting and python interactive mode
More examples of syntax highlighting and python interactive mode
Now I am developing a feature to list all functions and keywords from a specific python module imported during the program execution. I am using dir command to do it. This feature will provide these keywords to use in syntax highlighting and tab complete in a dynamic way. Then, python backend will support any python module, and not scipy, numpy, and matplotlib only.
Python backend is available in python-backend branch in Cantor repository. You can test it, but remember this code is not stable and finalized for now.
Hi.
I think there are problems with the images
Thanks ZeD. The plugin to copy images from URL to my server don’t worked this time, but I updated the post to fix it. =)
Cool 🙂
I know it’s a totally different stack of technologies, and it’s like a orange-to-apple comparison, but it reminds me of http://ipython.org/notebook.html
Do you plan something like that? Or maybe some integration?
Yes, I mentioned that in his previous blog post on this topic. iPython already has a Qt backend, support for HTML notebooks, multiple simultaneous notebooks, built-in pretty-printing and syntax highlighting, and what looks to be a pretty large API.
Hi Zed and TheBlackCat. TheBlackCat mentioned about iPython in previous blogpost. I read about iPython, it is wonderful project, but it delivery some additional and interesting features. However, my project aims develop a “more pure python” backend.
I think will be more interesting develop a specific iPython backend to use these additional features.
Well, I will think about create a iPython backend after this GSoC. =)
Pingback: Links 27/7/2013: More Android/Linux, Also Coming to TVs Now | Techrights
Will these features also be available in the Sage backend?
I can not test sage backend now, but these features are available in currently version of sage backend (in fact, these features are available since sage backend release).
Couldn’t the Sage and the Python backend share the same code for completion etc.?
Yes, parts of code in Sage and Python backends are similar. Maybe, dynamic keywords developed to Python backend can be used in Sage backend too.
Pingback: Cantor – dynamic keywords in python backend at Filipe Saraiva's blog