pylab set function in python 2.4

I'm all for having more consistent accessors for the various

    > object properties. Perhaps something like this would work
    > well? (yeah, it's modeled on Tkinter's configure() method)

    > # def set(cfgdict=None, **kwds) -> None
    > x.set(facecolor='r', size=2)

Well, the current approach is nothing if not consistent. The whole
"set" functionality is based upon the objects having property
setters. Eg, set(PROPERTYNAME=val) always calls
set_PROPERTYNAME(val)

The set function you propose is a good idea and trivial to write.
Just add this function to matplotlib.artist.Artist

    def set(self, **kwargs):
        """
        A tkstyle set command, pass kwargs to set properties
        """
        ret =
        for k,v in kwargs.items():
            k = k.lower()
            funcName = "set_%s"%k
            func = getattr(self,funcName)
            ret.extend( [func(v)] )
        return ret

I'll include this in the next release.

    > If anyone else is interested in working to develop a tutorial
    > for matplotlib's OO API, please drop me a line... I have a
    > vested interest in making matplotlib easier for busy
    > developers to use.

I suggest extending Robert's tutorial linked here

  http://matplotlib.sourceforge.net/faq.html#OO

Thanks!
JDH

    > I'm all for having more consistent accessors for the various
    > object properties. Perhaps something like this would work
    > well? (yeah, it's modeled on Tkinter's configure() method)

Well, the current approach is nothing if not consistent. The whole
"set" functionality is based upon the objects having property
setters. Eg, set(PROPERTYNAME=val) always calls
set_PROPERTYNAME(val)

In retrospect, "more consistent" was a poor choice of words. I believe I was thinking of some corner case where I had to do something like `obj.member.set_text("blah")' when I wrote it. Of course, I cannot find an example where you have to do this, so it's a good bet I was doing something daft.

    > If anyone else is interested in working to develop a tutorial
    > for matplotlib's OO API, please drop me a line... I have a
    > vested interest in making matplotlib easier for busy
    > developers to use.

I suggest extending Robert's tutorial linked here

  http://matplotlib.sourceforge.net/faq.html#OO

This tutorial looks like a great place to start. Thanks!

Ken

···

On May 24, 2005, at 1:42 PM, John Hunter wrote: