Exposing object model in Python?

Steve Holden sholden at holdenweb.com
Fri Jun 27 10:47:10 EDT 2003


"Fredrik Lundh" <fredrik at pythonware.com> wrote ...
> Steve Holden wrote:
>
> > > I'm writing a classical desktop application, using wxPython
> > > and some other libraries. I'm interested to expose its
> > > object model a la Microsoft's VBA. That is, I want to allow
> > > my users to tinker with the app, i.e. write their own macros
> > > in Python in a miniature IDE, within the app. I'd also like to ship
> > > the program as a standalone app, using py2exe.
>
> > Unfortunately the techniques used are a little too complicated to
describe
> > in a newsgroup posting.
> >
> > with-apologies-to-pierre-de-fermat-ly y'rs  - steve
>
>     macrosource = getmacro(macroname)
>     code = compile(macrosource, macroname, "exec")
>     context = {}
>     # populate context with fun things
>     context["app"] = object_representing_my_app
>     exec code in context
>
> (add exception handling as necessary)
>

You just *love* proving me wrong, don't you? Lucky for you I'm wrong so
often.

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/







More information about the Python-list mailing list