<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 17 October 2013 02:35, Felix Breuer <span dir="ltr"><<a href="mailto:felix@fbreuer.de" target="_blank">felix@fbreuer.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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?</blockquote>

</div><br></div><div class="gmail_extra">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:<br><br></div><div class="gmail_extra">def mymethod(self, arg):<br>

</div><div class="gmail_extra">    ...<br><br></div><div class="gmail_extra">MyClass.mymethod = mymethod<br><br></div><div class="gmail_extra">That's not ideal, but it should allow you to divide a class up into separate cells.<br>

<br></div><div class="gmail_extra">Thomas<br></div></div>