[PythonCAD] Anyone have experience with the parser module?

Art Haas ahaas at airmail.net
Thu Feb 10 15:59:53 CET 2005

On Thu, Feb 10, 2005 at 03:45:14PM +0100, Rafael Villar Burke wrote:
> Art Haas wrote:
> >Hi.
> >
> >I've been busy with non-computer related things lately, so there has
> >been very little PythonCAD development activity of late. I removed some
> >unused code here and there and a few routines that were scheduled to
> >disappear, but not much new code has appeared lately.
> >
> >While thinking about what parts of PythonCAD to work on, I began to
> >re-examine the handling of the commands, and in general how text from
> >the entry box at the bottom of the screen, is dealt with. Right now,
> >when text entry can provide data for a tool the usual way to handle this
> >is via eval(). That's all fine and good, but in view of the goal of
> >making the program scriptable this approach is too simplistic. A bit of
> >reading and tinkering with the 'exec' keyword demonstrated how it would
> >easy to add the ability to store variables and procedures on a per-image
> >basis. The key is storing in each image a dictionary that 'exec' can
> >populate with variables, functions, etc., as well as use previous stored
> >values. The syntax seems a bit odd though:
> > 
> >
> Hi,
> Well... I don't have experience with parser, but thinking about the 
> commands entry it reminded me this:
> Have you had a look at gazpacho [1]?. It's a pygtk app that uses a 
> CommandManager class and a Command class that wrap "commands and 
> arguments" and execute them. It also manages undo and redo work.
> The best point is that it may be safer than doing eval, as you don't 
> allow your program do anything directly. You could take a command and do 
> dispatching using a dict that has a key as command and a descriptor to 
> the right Command.run(command_variables) to use.
> Just an idea. Hope it helps. :)
> [1] http://gruppy.sicem.biz/componentes

I've not looked at gazpacho, but the approach they use sounds like
something I would be interested in. Thanks for the tip.

Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

More information about the PythonCAD mailing list