Pasting code into the cmdline interpreter

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Sep 22 04:31:02 EDT 2016


On Thursday 22 September 2016 17:42, eryk sun wrote:

> On Thu, Sep 22, 2016 at 5:12 AM, Veek M <vek.m1234 at gmail.com> wrote:
>> 2. Blank lines in my code within the editor are perfectly acceptable for
>> readability but they act as a block termination on cmd line.
> 
> You can write a simple paste() function. For example:
> 
>     import sys
>     paste = lambda: exec(sys.stdin.read(), globals())

Nice!



-- 
Steven
git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.




More information about the Python-list mailing list