Python -Vs- Ruby: A regexp match to the death!

Robert Kern robert.kern at gmail.com
Mon Aug 9 21:59:10 EDT 2010


On 8/9/10 4:43 PM, Stefan Schwarzer wrote:
> Hi Robert,
>
> On 2010-08-09 22:23, Robert Kern wrote:
>> On 2010-08-09 06:42 , Stefan Schwarzer wrote:
>>> Unfortunatey, when I enter
>>>
>>>     In [2]: %paste
>>>
>>> at the prompt it gives me (before I pasted anything)
>>>
>>>     In [2]: %paste
>>>     ------------------------------------------------------------
>>>        File "<string>", line 1
>>>          http://pypi.python.org/pypi/ipython/0.10
>>>              ^
>>>     SyntaxError: invalid syntax
>>
>> Yes, that's because you had that URL in your clipboard, not Python code. What
>> were you expecting to happen?
>
> I got that traceback as soon as I typed in "%paste" and
> pressed enter, without pasting anything in the terminal.
> I had assumed it works like :paste in Vim, activating a
> kind of "paste mode" where everything pasted into the
> terminal is modified as the help text suggests.

%cpaste will do that. I implemented %paste because not all terminals will 
correctly paste arbitrary amounts of code correctly. Grabbing the text directly 
from the clipboard is less error-prone and removes redundant user interaction.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list