Prev: Win7. Why Don't Matplotlib, ... Show up in Control Panel Add-Remove?
Next: requirements in writing an email/rss/usenet client?
From: Mike Kent on 9 Aug 2010 09:19 On Aug 8, 8:43 pm, rantingrick <rantingr...(a)gmail.com> wrote: > Hello folks, > > You all know i been forced to use Ruby and i am not happy about that. ***Blablabla cut long rant*** Xah, this is really you, isn't it. Come on, confess.
From: Robert Kern on 9 Aug 2010 16:23 On 2010-08-09 06:42 , Stefan Schwarzer wrote: > Hi Steven, > > On 2010-08-09 10:21, Steven D'Aprano wrote: >> And that it's quite finicky about blank lines between methods and inside >> functions. Makes it hard to paste code directly into the interpreter. >> >> And that pasting doesn't strip out any leading prompts. It needs a good >> doctest mode. > > ipython [1] should help here: > > IPython 0.10 -- An enhanced Interactive Python. > ? -> Introduction and overview of IPython's features. > %quickref -> Quick reference. > help -> Python's own help system. > object? -> Details about 'object'. ?object also works, ?? prints more. > In [1]: %paste? > Type: Magic function > Base Class:<type 'instancemethod'> > String Form:<bound method InteractiveShell.magic_paste of<IPython.iplib.InteractiveShell object at 0xb740096c>> > Namespace: IPython internal > File: /usr/lib/pymodules/python2.6/IPython/Magic.py > Definition: %paste(self, parameter_s='') > Docstring: > Allows you to paste& execute a pre-formatted code block from clipboard. > > The text is pulled directly from the clipboard without user > intervention. > > 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. '%paste foo'. > This assigns the pasted block to variable 'foo' as string, without > dedenting or executing it (preceding>>> and + is still stripped) > > '%paste -r' re-executes the block previously entered by cpaste. > > IPython statements (magics, shell escapes) are not supported (yet). > > See also > -------- > cpaste: manually paste code into terminal until you mark its end. > > 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? -- 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
From: Stefan Schwarzer on 9 Aug 2010 17:43 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. Ok, I just noticed I should have actually _read_ the help text, not just scanned it. ;-) Sorry for the confusion. Stefan
From: Stefan Schwarzer on 9 Aug 2010 17:47 On 2010-08-09 23:43, Stefan Schwarzer wrote: > 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 I meant ":set paste" of course. Stefan
From: sturlamolden on 9 Aug 2010 21:51
On 9 Aug, 10:21, Steven D'Aprano <st...(a)REMOVE-THIS- cybersource.com.au> wrote: > And that it's quite finicky about blank lines between methods and inside > functions. Makes it hard to paste code directly into the interpreter. The combination of editor, debugger and interpreter is what I miss most from Matlab. In Matlab we can have a function or script open in an editor, and use it directly from the interpreter. No need to reimport or anything: edit and invoke. It is also possible to paste data directly from the clipboard into variables in the interpreter. ipython does not have that annoying >>> prompt. |