cpaste(self, parameter_s='')
You must terminate the block with '--' (two minus-signs) or Ctrl-D alone on the line. You can also provide your own sentinel with '%paste -s %%' ('%%' is the new sentinel for this operation).
The block is dedented prior to execution to enable execution of method definitions. '>' and '+' characters at the beginning of a line are ignored, to allow pasting directly from e-mails, diff files and doctests (the '...' continuation prompt is also stripped). The executed block is also assigned to variable named 'pasted_block' for later editing with '%edit pasted_block'.
You can also pass a variable name as an argument, e.g. '%cpaste foo'. This assigns the pasted block to variable 'foo' as string, without dedenting or executing it (preceding >>> and + is still stripped)
'%cpaste -r' re-executes the block previously entered by cpaste. '%cpaste -q' suppresses any additional output messages.
Do not be alarmed by garbled output on Windows (it's a readline bug). Just press enter and type -- (and press enter again) and the block will be what was just pasted.
Shell escapes are not supported (yet).
Paste & execute a pre-formatted code block from clipboard.
paste
automatically pull code from clipboard.
In [8]: %cpaste Pasting code; enter '--' alone on the line to stop. :>>> a = ["world!", "Hello"] :>>> print(" ".join(sorted(a))) :-- Hello world!
In [8]: %cpaste
Pasting code; enter '--' alone on the line to stop. :>>> %alias_magic t timeit :>>> %t -n1 pass :-- Created :None:None:`%t`
as an alias for :None:None:`%timeit`
. Created :None:None:`%%t`
as an alias for :None:None:`%%timeit`
. 354 ns ± 224 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)
The following pages refer to to this document either explicitly or contain code examples using this.
IPython.terminal.magics.TerminalMagics.paste
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them