eryk sun wrote:

> On Thu, Sep 22, 2016 at 5:12 AM, Veek M <vek.m1...@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())
> 
>     >>> paste()
>     class Foo:
>         """test class"""
> 
>         def spam(self):
>             '''test method'''
>             return 'eggs'
> 
>     >>> Foo().spam()
>     'eggs'
> 
> In a Unix terminal and IDLE, stdin.read() is terminated by typing
> Ctrl+D at the start of an empty line. For the Windows console, it's
> Ctrl+Z, Enter. Actually in a Unix terminal the cursor can also be at
> the end of a line, but a bug in Python requires pressing Ctrl+D twice
> in that case.

ah! very clever and many thanks! so, you use .pythonrc.py to 
store/define your cmd-line shortcuts.

It doesn't work in python2.x, because exec is a stmt, so, def paste(
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to