[IPython-dev] %history and %rep
Hans Meine
hans_meine@gmx....
Fri May 25 03:12:07 CDT 2007
Am Donnerstag, 24. Mai 2007 23:11:34 schrieb Ville M. Vainio:
> %rep should use str(_) as the input line. I.e. the stringized version
> of the last result. Ever looked at those strings on variables that are
> so close yet so far, i.e. require you to do the productivity-killing
> chore of mouse-console-copypaste? Now you could do:
>
> $ l = ["hei", "vaan"]
>
> $ "".join(l)
>
> ==> heivaan
>
> $ rep
>
> $ heivaan_ <== cursor blinking
>
> I've often wanted to construct the input line and then edit it, but it
> always required copy-paste...
That is indeed a good idea (save the above rationale for the docs BTW).
I wonder whether %rep is a good name though.
Second, I want to say that your %rep 2 4 3:5 is a good idea, too - I very
often define a macro "redo" only to repeat several steps at once.
Speaking of that - I often make the mistake that I pass comma-separated line
numbers to %macro, e.g. "macro redo 4,5,7:10", which always throws "invalid
literal for int()". I would have provided a patch for extract_input_slices,
but what do you think about that? It could then also support "4,5,7-8". Oh,
it already supports "-" ranges, so I guess splitting on "," would not appear
as a bad idea to anyone then?
Attached you'll find a small patch that does that, and also handles strange
input like the latter examples:
%macro redo 4,5,7:10,15-16
%macro redo 4, 5, 7:10, 15-16
%macro redo 1,2 4 , 5, 7:10 15-16
Ciao, / /
/--/
/ / ANS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipython-extract_input_slices.diff
Type: text/x-diff
Size: 449 bytes
Desc: not available
Url : http://lists.ipython.scipy.org/pipermail/ipython-dev/attachments/20070525/358fdaef/attachment.bin
More information about the IPython-dev
mailing list