Sunday, June 28, 2009

lab 103 - python content assist


lab 103 - python content assist


Building on lab 102 I've started to write an acme client for python content-assist in python. I read the code for python's IDLE editor and pulled some pieces out of that to help with my implementation. The and modules are copied out of idlelib and reduced to just the functions I needed.

Just as in lab 102 the acme client is implemented using pyxp to connect to the acme file system.

In an acme editor window execute PyAssist. Start typing some python. After typing a dot the client will display available attributes for the module. Continue typing and it will reduce the list to those names with a matching prefix. Press the Tab key to complete a name or prefix depending on whether there is one or more names.


After typing an open parenthesis the client will show the call tip for the function.


The client implements an Import command so that more python modules can be added to the namespace. PyAssist doesn't attempt to parse the edited script. Idlelib includes code that could help to do this. But for now you need to pass a module name as argument to the Import command.

A next step for python integration to acme is to implement a debugger. Python comes with libraries for this too, so a debugger similar to the acme debugger adeb should be a future lab. I might then run edited scripts in a sub shell and inspect that process' namespace similar to the IDLE implementation, so that content-assist adapts to the script being edited.




Peter Schwier said...

How did you run python inside inferno? I tried running 8c.exe inside inferno but that would not even run.

I'm trying to figure out how to run programs written in other languages inside inferno. Is that even possible?

caerwyn said...

Python is run outside of inferno using the os(1) command so it appears that it is running inside. E.g. the contents of a python inferno shell script might be the following:

os -T python $*

The PyAssist code connects to inferno using the 9p protocol and the library so it can read the acme(4) file system. But all that python code is running outside inferno.

Peter Schwier said...

Thanks! That's what I was missing in trying to figure this out.

I'm fairly sure I can figure the rest of it out. It was just stuck in my mind that I had to compile C code to dis VM in order to run it inside inferno.