Pasting code into the cmdline interpreter
Christian Gollwitzer
auriocus at gmx.de
Thu Sep 22 02:19:22 EDT 2016
Am 22.09.16 um 07:12 schrieb Veek M:
> I wanted to test this piece of code which is Kate (editor) on the cmd
> line python >>> prompt:
> 2. Blank lines in my code within the editor are perfectly acceptable for
> readability but they act as a block termination on cmd line. So if i
> paste:
> tex_matches = re.findall(r'(\\\w+{.+?})|(\\\w+)', msg)
> for tex_word in tex_matches:
> repl = unicode_tex.tex_to_unicode_map.get(tex_word)
>
> if repl is None:
>
> I get:
> IndentationError: unexpected indent
IPython has a %paste and %cpaste magic to deal with this and other
problems. It won't resolve the tab issue. However, Python code in
general (due to indentation) is not very friendly for pasting and
interactive usage. Better write the code to a file, then (again from
IPython) you can read this by %run filename.py
Christian
More information about the Python-list
mailing list