[IPython-dev] [nbconvert] Reining in the number of constructor arguments

Thomas Kluyver takowl@gmail....
Fri Nov 30 17:44:53 CST 2012


On 30 November 2012 23:05, David Warde-Farley <d.warde.farley@gmail.com>wrote:

> I'm wondering how to solve (and how you guys think I should solve) a
> certain problem I foresee, of a potentially rapidly growing number of
> constructor arguments for Converter classes, which need to be
> maintained across constructors in order to keep the front-end calling
> code generic (one could use *args and **kwargs catch-alls but that's
> pretty ugly).
>

I may be barking up the wrong tree, but instead of constructor arguments,
would it make sense to simply set attributes on the converter, e.g.

conv = HTMLConverter()
conv.highlight_source = False

This is the route I went for in a recent nbviewer PR:
https://github.com/ipython/nbviewer/pull/10/files#L0R127

This gives us simple introspection by looking at the attributes, and
classes will ignore irrelevant options, so long as we don't get conflicting
names. We could also allow setting them from the constructor using **kwargs.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20121130/942b5d58/attachment.html 


More information about the IPython-dev mailing list