Is %doctest_mode fully functional and reliable inside Spyder v3.2.4?

28 views
Skip to first unread message

Dave Jones

unread,
Dec 15, 2017, 9:38:10 AM12/15/17
to spyder
I'm new to Spyder so maybe I'm missing something?

Inside Spyder 3.2.4-py36h908396f_0 via conda 4.3.30 on Mac OSX 10.12.3

Python 3.6.3 |Anaconda, Inc.| (default, Dec  5 2017, 17:30:25)
Type "copyright", "credits" or "license" for more information.

IPython 6.2.1 -- An enhanced Interactive Python.

Restarting kernel... 

In [1]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON

In [2]: 

Notice that the prompt did not change to >>>

----------
[invoking from bash shell works s expected]

localhost:~/miniconda3/bin/ipython3
Python 3.6.3 |Anaconda, Inc.| (default, Dec  5 2017, 17:30:25)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

In [1]:

In [1]: %doctest_mode
Exception reporting mode: Plain
Doctest mode is: ON

>>>

Is this cause for concern?

Thanks

Carlos Córdoba

unread,
Dec 15, 2017, 9:39:52 AM12/15/17
to spyd...@googlegroups.com
Hey,

What's %doctest_mode used for?


Cheers,
Carlos

El 15/12/17 a las 01:26, Dave Jones escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Dave Jones

unread,
Dec 15, 2017, 3:18:25 PM12/15/17
to spyder

%doctest_mode

Toggle doctest mode on and off.

This mode is intended to make IPython behave as much as possible like a plain Python shell, from the perspective of how its prompts, exceptions and output look. This makes it easy to copy and paste parts of a session into doctests. It does so by:

  • Changing the prompts to the classic >>> ones.
  • Changing the exception reporting mode to ‘Plain’.
  • Disabling pretty-printing of output.

Note that IPython also supports the pasting of code snippets that have leading ‘>>>’ and ‘...’ prompts in them. This means that you can paste doctests from files or docstrings (even if they have leading whitespace), and the code will execute correctly. You can then use ‘%history -t’ to see the translated history; this will give you the input after removal of all the leading prompts and whitespace, which can be pasted back into an editor.

With these features, you can switch into this mode easily whenever you need to do testing and changes to doctests, without having to leave your existing IPython session.

Carlos Córdoba

unread,
Dec 15, 2017, 3:55:34 PM12/15/17
to spyd...@googlegroups.com
I see. Well, it seems that mode doesn't work in Spyder's embedded IPython console. You can report this problem at

https://github.com/jupyter/qtconsole

but I doubt a solution will come for this soon.


Cheers,
Carlos

El 15/12/17 a las 11:16, Dave Jones escribió:
Reply all
Reply to author
Forward
0 new messages