[IPython-dev] splitting a class definition across cells in notebook
Thomas Kluyver
takowl at gmail.com
Thu Oct 17 10:13:18 EDT 2013
On 17 October 2013 02:35, Felix Breuer <felix at fbreuer.de> wrote:
> I am working on an IPython notebook in which I want to explain the
> definition of a class in detail. (Think literate programming.) In
> particular, I want to interleave the definition of the individual methods
> of a class with Markdown cells explaining in detail what is going on.
> However, as far as I have been able to find out, I have to put the entire
> class definition in a single cell - and there is no way to amend this
> definition later on. Is there any way around this?
One rough way to do this would be to define each method as a function, and
assign it to the class at the end of its cell. Like this:
def mymethod(self, arg):
...
MyClass.mymethod = mymethod
That's not ideal, but it should allow you to divide a class up into
separate cells.
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20131017/f569f1f1/attachment.html>
More information about the IPython-dev
mailing list