From: Todd <tod...@gm...> - 2013-02-08 10:30:58
|
On Fri, Feb 8, 2013 at 2:40 AM, Antony Lee <ant...@be...> wrote: > Hi, > > I saw that a discussion started on transitioning to the use of properties > instead of explicit getters and setters, which seems like a very good idea > to me... so I thought this would be a good idea to get involved in > matplotlib-devel :) > > Right now an issue raised is what to do with set_* that take multiple > arguments. Taking set_title, which takes both positional and keyword > arguments, as an example, my idea would be to do > > ax.title = "A title" > ax.title.fontdict = fontdict > > Basically, a property "foo" (in the matplotlib meaning of the word) > becomes a descriptor with __get__ => get_foo and __set__ => set_foo, and > keyword arguments to the old property setter become themselves descriptors > on that descriptor. > > Antony > > I think this makes it over-complicated. It is much simpler, more explicit, and more consistent to have two properties here, one that only deals with a string, and a second that only deals with a text object. Then you can do something like (where titletext returns the text object): ax.titletext.fontdict That way we automatically get what you want without any additional work or fancy tricks in a much cleaner, more explicit, and more predictable manner. |