[IPython-dev] [nbconvert] Reining in the number of constructor arguments
Fri Nov 30 17:44:53 CST 2012
On 30 November 2012 23:05, David Warde-Farley <firstname.lastname@example.org>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:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev