[IPython-dev] [Ipython-svndiff] 2885 - Do not replace # w/ \# anymore

Fernando Perez fperez.net@gmail....
Tue Dec 11 00:55:24 CST 2007


On Dec 7, 2007 3:59 AM,  <ipython-svndiff@scipy.org> wrote:
> Author: vivainio
> Date: 2007-12-07 04:59:06 -0600 (Fri, 07 Dec 2007)
> New Revision: 2885
>
> Modified:
>    ipython/trunk/IPython/Extensions/ipy_profile_sh.py
>    ipython/trunk/IPython/iplib.py
> Log:
> Do not replace # w/ \# anymore
>
> Modified: ipython/trunk/IPython/Extensions/ipy_profile_sh.py
> ===================================================================
> --- ipython/trunk/IPython/Extensions/ipy_profile_sh.py  2007-12-02 04:42:21 UTC (rev 2884)
> +++ ipython/trunk/IPython/Extensions/ipy_profile_sh.py  2007-12-07 10:59:06 UTC (rev 2885)
> @@ -134,7 +134,7 @@
>      # utility to expand user variables via Itpl
>      # xxx do something sensible with depth?
>      ip.IP.var_expand = lambda cmd, lvars=None, depth=2: \
> -        str(ItplNS(cmd.replace('#','\#'), ip.IP.user_ns, get_locals()))
> +        str(ItplNS(cmd, ip.IP.user_ns, get_locals()))

Mmh, when replacing code like this, which was obviously put in there
explicitly and for some reason, please double check with others first.
 While I realize that the lack of any automatic test makes this
harder, code like what was there didn't end up that way by accident,
so there must have been a reason for it.

In this case, the behavior that was in there was to ensure
compatibility with the shell:

In [1]: !echo hi # cmd
hi # cmd

Which is how the shell behaves:

maqroll[~]> echo hi # cmd
hi # cmd

Now, after the above commit:

In [1]: !echo hi # cmd
hi

I won't revert (yet) the commit  because I imagine there was a reason
for it, but the right approach is to find a solution for both needs,
not to blindly break what was in there.

Cheers,

f


More information about the IPython-dev mailing list