[IPython-dev] splitting a class definition across cells in notebook
Gregor Thalhammer
gregor.thalhammer at gmail.com
Thu Oct 17 09:42:30 EDT 2013
> Hello everyone!
>
> 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?
On the python side you could play some tricks, using inheritance or manually adding functions to classes to spread out the class definition across several cells.
class A(object):
name = 'you'
def hi(self):
print 'hi', self.name
a = A()
a.hi()
def ho(self):
print 'ho', self.name
A.ho = ho
a.ho()
class A2(A):
def ho(self):
print 'ho', self.name
a2 = A2()
a2.ho()
Gregor
More information about the IPython-dev
mailing list