[IPython-dev] automatic quoting in interactive shell

Brian Wylie briford.wylie at gmail.com
Tue Jul 22 18:44:58 EDT 2014


class my_transformer(IPython.core.prefilter.PrefilterTransformer):
    def transform(self, line, continue_prompt):
        if line.startswith('help'):
            return ','+line
        else:
            return line

I have a custom interactive shell where I want the help to be 'roll face on
keyboard' simple....

> help
> help load
> help meta
> help view

I have cfg.InteractiveShellEmbed.autocall = 2

so these all expand out to a form like.. workbench.help("load") ....

I can see after some experimenting that my 'hack' may be quite a PITA if it
gets invoked when people don't want it.. which I'm sure is why you
guys/gals don't really want it in the main IPython.

I'll poke around inside the prefilter code and also look at doing a custom
completer. Probably at some point the hack above will piss me off and I'll
rip it out :)

Thanks again for all the info,
-bri


On Tue, Jul 22, 2014 at 4:34 PM, Thomas Kluyver <takowl at gmail.com> wrote:

> On 22 July 2014 15:30, Brian Wylie <briford.wylie at gmail.com> wrote:
>
>> Okay, the transformer approach worked amazingly well. It's a bit of a
>> hack the transformer simply adds a ',' to the beginning of lines where I'm
>> calling commands that need to be 'auto-quoted'.. but certainly speaks well
>> of the IPython design that my hack worked so quickly. :)
>
>
> Well, I'm glad it worked. How are you deciding which lines need that
> treatment?
>
> There are two bits of machinery transforming input in IPython. Input
> transformers handle things where you can tell just from looking at the
> line, like %magic and !shell commands. Then the prefilter machinery changes
> things that depend on what's in the current namespace, like autocall.
>
> Thomas
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140722/2f4f6c31/attachment.html>


More information about the IPython-dev mailing list