[IPython-user] Macros & slice notation
Fernando Perez
Fernando.Perez at colorado.edu
Sat Dec 31 17:17:17 CST 2005
Fernando Perez wrote:
> Ville Vainio wrote:
>
>>On 12/30/05, Fernando Perez <Fernando.Perez at colorado.edu> wrote:
>>
>>
>>
>>>recipe for unnecessary confusion (think perl). I'd rather have one, good and
>>>intuitive way to do it: the human brain (at least mine :) is good at
>>>remembering specific use cases, as long as they remain reasonably orthogonal.
>>
>>
>>Well, if you want an intuitive way, I think it speaks directly for 1-3
>>as 1..3! :-)
>>
>>1:4 is always a gotcha, one extra thing to remember, one extra brain
>>cycle, one thing that stops you from getting the direct "do what I
>>mean" experience. Because it's a %magic it basically boils down to
>>"what feels most comfortable", not "what is just like the rest of
>>python". Think $var string interpolation etc.
>>
>>Plus, you are bumping the major version number so this is your break
>>at changing it. :-).
>
>
> OK, N-M it is then. I agree with your arguments about "magics are not python
> already, so let's just make them as convenient to use as possible". As for
> N--M, it's too latex-y for my taste (if we were to use proper math notation,
> we'd allow [N,M) for N...M-1, [N,M] for N..M, etc :).
>
> I'll code in the patches in a minute and will commit later.
OK, I just committed this. As it turns out, due to the way the underlying
implementation works, the N:M notation (for N..M-1) still works. It would
have broken other things to remove it (or made the code unnecessarily
complex), so I just left it in. The docstring now reads:
The notation for indicating number ranges is: n1-n2 means 'use line
numbers n1,...n2' (the endpoint is included). That is, '5-7' means
using the lines numbered 5,6 and 7.
Note: as a 'hidden' feature, you can also use traditional python slice
notation, where N:M means numbers N through M-1.
So hopefully this will satisfy most people (sorry Alan :)
OK, Happy New Year to everybody, and please report any problems. I just
uploaded 0.7.0.rc5, which has a number of important fixes I made last night.
Some pounding on this would be very welcome. My target release date for 0.7.0
is around Jan 10, give or take a few days.
Cheers,
f
More information about the IPython-user
mailing list