[Edu-sig] [Update] re: Does edu-sig extend to Jython

Arthur ajs@ix.netcom.com
Sun, 15 Sep 2002 15:43:30 -0400


Thought I'd share an update on my efforts to solve what I had termed a
"method loading" issue in trying to achieve
the scripting interface I had envisioned for PyGeo.

The discussion is in the August edu-sig archive.

I had written -

>And in doing some real error catching and reporting on arguments,
>I would expect isinstance will come into play, and in
>doing it, it should not be very much additional burden to
>do it in such a way so that at least I can make argument
>order irrelevant.

>After that I guess I need to see where I am, and then take the more
>complex issues of this kind on a case by case basis - there
>probably is no one-size answer for all cases.

Turns out "issubclass", rather than "issinstance", was the key to
accomplishing what I wanted.

And I was able to accomplish everything I had hoped - methods called based
on passed arguments (order insensitive), error reporting of invalid argument
sets,etc. - with a ten line function.  The function is currently, BTW, ugly
and broken - but basically funtional.  I will get it refined in due course.

Using this, and the occasional string qualifier, there are in the end going
to be maybe 15 "argument smart" classes with which the user interacts,
rather the 40 to 50 there had been.

Another BTW:

I also wanted to be lenient in terms of the passing of string qualifiers.
"CircumCenter", "Cirumcenter", "Circum_Center", "Circum_center" all
acceptable.Was simple to implement.

So whether I have made the right choices for my Scripting Interfacte remains
to be seen. But in the end Python posed no limitation on allowing me to
implement exactly what I envisioned, in all essential respects.

Also satisfying that I have been able to implement a serviceable (though not
perfect) Observer pattern in a few lines of Python. Essentially as classes
are instantiated, its arguments, and recursively, the arguments to its
argments, are inspected. The class instance is registered to any of these
arguments which are accessible for manipulation to the user through the GUI.
The result, of course, is that when a point (for example)  is interactively
picked and moved, only the class instances registered
with it need to be updated.  Significant performance benefit  - depending on
the complexity of the construction.

In short, having much fun.

Art