diff --git a/converters/python.py b/converters/python.py index 5b0bf2d..7607e05 100755 --- a/converters/python.py +++ b/converters/python.py @@ -33,16 +33,21 @@ class ConverterPy(Converter): return ['#{0} {1}'.format('#'*cell.level, cell.source), ''] def render_code(self, cell): + try: + prompt_number = cell.prompt_number + except AttributeError: + prompt_number = " " + if not cell.input: return [] lines = [] if self.show_prompts: - lines.extend(['# In[%s]:' % cell.prompt_number]) + lines.extend(['# In[%s]:' % prompt_number]) src = cell.input lines.extend([src, '']) if self.show_output: if cell.outputs : - lines.extend(['# Out[%s]:' % cell.prompt_number]) + lines.extend(['# Out[%s]:' % prompt_number]) for output in cell.outputs: conv_fn = self.dispatch(output.output_type) lines.extend(conv_fn(output)) diff --git a/converters/rst.py b/converters/rst.py index 1e626ee..09ddcaf 100755 --- a/converters/rst.py +++ b/converters/rst.py @@ -11,10 +11,16 @@ class ConverterRST(Converter): return ['{0}\n{1}\n'.format(cell.source, marker * len(cell.source))] def render_code(self, cell): + # Note: cell has type 'IPython.nbformat.v3.nbbase.NotebookNode' if not cell.input: return [] - lines = ['In[%s]:' % cell.prompt_number, ''] + try: + prompt_number = cell.prompt_number + except AttributeError: + prompt_number = " " + + lines = ['In[%s]:' % prompt_number, ''] lines.extend(rst_directive('.. code:: python', cell.input)) for output in cell.outputs: